Re: [PATCH v3] scsi: report 'INQUIRY result too short' once per host

2015-10-12 Thread Hannes Reinecke
On 10/12/2015 05:16 PM, Vitaly Kuznetsov wrote:
> Hannes Reinecke  writes:
> 
>> On 10/08/2015 06:54 PM, Vitaly Kuznetsov wrote:
>>> Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
>>> SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
>>> least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
>>> INQUIRY result too short (5), using 36' messages on console. This can be
>>> problematic for slow consoles. Introduce short_inquiry flag in struct
>>> Scsi_Host to print the message once per host.
>>>
>>> Signed-off-by: Vitaly Kuznetsov 
>>> ---
>>> Changes since v2:
>>> - This is a successor of previously sent (and still not merged) "scsi:
>>>   introduce short_inquiry flag for broken host adapters" patch. I'm not
>>>   particularly sure which solution is better but I'm leaning towards this
>>>   one as it doesn't require changes to adapter drivers.
>>> ---
>>>  drivers/scsi/scsi_scan.c | 9 ++---
>>>  include/scsi/scsi_host.h | 3 +++
>>>  2 files changed, 9 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>>> index f9f3f82..cd347e4 100644
>>> --- a/drivers/scsi/scsi_scan.c
>>> +++ b/drivers/scsi/scsi_scan.c
>>> @@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, 
>>> unsigned char *inq_result,
>>>  * strings.
>>>  */
>>> if (sdev->inquiry_len < 36) {
>>> -   sdev_printk(KERN_INFO, sdev,
>>> -   "scsi scan: INQUIRY result too short (%d),"
>>> -   " using 36\n", sdev->inquiry_len);
>>> +   if (!sdev->host->short_inquiry) {
>>> +   shost_printk(KERN_INFO, sdev->host,
>>> +   "scsi scan: INQUIRY result too short (%d),"
>>> +   " using 36\n", sdev->inquiry_len);
>>> +   sdev->host->short_inquiry = 1;
>>> +   }
>>> sdev->inquiry_len = 36;
>>> }
>>>  
>> At least you need to check if you've received any valid data here;
>> 'INQUIRY result too short' is also a common error if the interrupt
>> is hosed when trying to access the device.
>> So please check for 'inquiry_len > 4' before setting 'short_inquiry'.
> 
> Currently we proceed even with a shorter reply... Should we abort the
> scan (and return -EOI?) in case we got inquiry_len <= 4?
> 
Yes please. We need to ensure that we actually received some data,
and not running into an error scenario here.
So we need to read at least five bytes of data, as byte 4 carries
the response length. If we read less than that we have no way of
figuring out if the response data is even remotely sane.

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/25] scsi: hisi_sas: add phy SAS ADDR initialization

2015-10-12 Thread Hannes Reinecke
On 10/12/2015 05:20 PM, John Garry wrote:
> This SAS ID is chosen as Huawei IEEE id: 001882
> 
> Signed-off-by: John Garry 
> ---
>  drivers/scsi/hisi_sas/hisi_sas_init.c | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
> b/drivers/scsi/hisi_sas/hisi_sas_init.c
> index 44fc524..c295c39 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_init.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
> @@ -283,6 +283,19 @@ err_out:
>   return NULL;
>  }
>  
> +static void hisi_sas_init_add(struct hisi_hba *hisi_hba)
> +{
> + u8 i;
> +
> + /* Huawei IEEE id (001882) */
> + for (i = 0; i < hisi_hba->n_phy; i++)
> + hisi_hba->phy[i].dev_sas_addr =
> + cpu_to_be64(0x5001882016072015ULL);
> +
Ouch. Each phy has the same SAS address?
For all boards? Ever?

Not sure if that's a good idea, nor even valid.
It'll confuse the hell out of any SAS array.

Please provide a means of having individual SAS addresses for each HBA.

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bugs in multipath scsi in 4.3-rc2

2015-10-12 Thread Hannes Reinecke
On 10/12/2015 09:36 PM, Christoph Hellwig wrote:
> On Mon, Oct 12, 2015 at 03:29:45PM -0400, Mike Snitzer wrote:
>> What may be getting lost during this discussion is that historically
>> it has been important to be able to attach the scsi_dh during the SCSI
>> scan.  As the scsi_dh alters the SCSI midlayer's sense code processing
>> (via callout to the attached scsi_dh).  And this altered SCSI sense
>> code handling amounts to the difference between a successful/quick
>> boot versus hugely delayed and ultimately error-prone boot on systems
>> with many LUNs that have multiple paths.
>>
>> So that is why either of these solutions were deployed:
>> 1) in RHEL6 we'd require dracut to preload the scsi_dh modules early
>> in loading the initramfs
>> 2) in RHEL7 all scsi_dh modules _are_ builtin
>>
>> Both achieve the goal of having all required scsi_dh available during SCSI 
>> scan.
> 
> Yes, and both are workarounds.  I tried to implement this properly,
> but due to async probing it doesn't actually work.  Given the statement
> from Tejun I don't really see how to ever get it to work as long as
> we use async probing and the module loading code isn't safe to call
> from the async probe path unfortunately.
> 
We've originally designed them to be modular as some handler
(notably emc, netapp, and alua) are mutually exclusive, ie you could
load either the alua or one of the vendor specific ones.

In the light of the discussion I think it would be better to
upgrade the device handler to become their own transport class,
to be hooked in between scsi_target and scsi_device.
That way we would have a way of exposing the topology (target port
groups etc) and would get rid of the probing problem.

It would mean that effectively the device handler would be
demodularized and become a compile-time option, but even that
wouldn't be too much of an issue, seeing that most vendors load
the modules unconditionally anyway.
(BTW, SUSE also loads the modules unconditionally ...)

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: advansys needs ISA dma api for ISA support

2015-10-12 Thread Hannes Reinecke
On 10/12/2015 05:10 PM, Arnd Bergmann wrote:
> The advansys drvier uses the request_dma function that is used on ISA
> machines for the internal DMA controller, which causes build errors
> on platforms that have ISA slots but do not provide the ISA DMA API:
> 
> drivers/scsi/advansys.c: In function 'advansys_board_found':
> drivers/scsi/advansys.c:11300:10: error: implicit declaration of function 
> 'request_dma' [-Werror=implicit-function-declaration]
> 
> The problem now showed up in ARM randconfig builds after commit
> 6571fb3f8b7f ("advansys: Update to version 3.5 and remove compilation
> warning") made it possible to build on platforms that have neither
> VIRT_TO_BUS nor ISA_DMA_API but that do have ISA.
> 
> This adds the missing dependency.
> 
> Signed-off-by: Arnd Bergmann 
> 
> diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
> index d2f480b04a52..d4aa6a1a806c 100644
> --- a/drivers/scsi/Kconfig
> +++ b/drivers/scsi/Kconfig
> @@ -499,6 +499,7 @@ config SCSI_ADVANSYS
>   tristate "AdvanSys SCSI support"
>   depends on SCSI
>   depends on ISA || EISA || PCI
> + depends on ISA_DMA_API || !ISA
>   help
> This is a driver for all SCSI host adapters manufactured by
> AdvanSys. It is documented in the kernel source in
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/25] scsi: hisi_sas: add ssp command function

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test ERROR on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
config: m68k-allmodconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k 

All error/warnings (new ones prefixed by >>):

   drivers/scsi/hisi_sas/hisi_sas_main.c: In function 'hisi_sas_task_prep':
>> drivers/scsi/hisi_sas/hisi_sas_main.c:169:2: error: implicit declaration of 
>> function 'dma_pool_alloc' [-Werror=implicit-function-declaration]
 slot->status_buffer = dma_pool_alloc(hisi_hba->status_buffer_pool,
 ^
>> drivers/scsi/hisi_sas/hisi_sas_main.c:169:22: warning: assignment makes 
>> pointer from integer without a cast
 slot->status_buffer = dma_pool_alloc(hisi_hba->status_buffer_pool,
 ^
   drivers/scsi/hisi_sas/hisi_sas_main.c:176:22: warning: assignment makes 
pointer from integer without a cast
 slot->command_table = dma_pool_alloc(hisi_hba->command_table_pool,
 ^
>> drivers/scsi/hisi_sas/hisi_sas_main.c:226:2: error: implicit declaration of 
>> function 'dma_pool_free' [-Werror=implicit-function-declaration]
 dma_pool_free(hisi_hba->sge_page_pool, slot->sge_page,
 ^
   cc1: some warnings being treated as errors
--
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c: In function 'prep_prd_sge_v1_hw':
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:822:2: error: implicit declaration of 
>> function 'dma_pool_alloc' [-Werror=implicit-function-declaration]
 slot->sge_page = dma_pool_alloc(hisi_hba->sge_page_pool, GFP_ATOMIC,
 ^
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:822:17: warning: assignment makes 
>> pointer from integer without a cast
 slot->sge_page = dma_pool_alloc(hisi_hba->sge_page_pool, GFP_ATOMIC,
^
   cc1: some warnings being treated as errors

vim +/dma_pool_alloc +169 drivers/scsi/hisi_sas/hisi_sas_main.c

   163  slot->n_elem = n_elem;
   164  slot->dlvry_queue = dlvry_queue;
   165  slot->dlvry_queue_slot = dlvry_queue_slot;
   166  cmd_hdr_base = hisi_hba->cmd_hdr[dlvry_queue];
   167  slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot];
   168  
 > 169  slot->status_buffer = 
 > dma_pool_alloc(hisi_hba->status_buffer_pool,
   170   GFP_ATOMIC,
   171   &slot->status_buffer_dma);
   172  if (!slot->status_buffer)
   173  goto err_out_slot_buf;
   174  memset(slot->status_buffer, 0, HISI_SAS_STATUS_BUF_SZ);
   175  
   176  slot->command_table = 
dma_pool_alloc(hisi_hba->command_table_pool,
   177   GFP_ATOMIC,
   178   &slot->command_table_dma);
   179  if (!slot->command_table)
   180  goto err_out_status_buf;
   181  memset(slot->command_table, 0, HISI_SAS_COMMAND_TABLE_SZ);
   182  memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
   183  
   184  tei.hdr = slot->cmd_hdr;
   185  tei.task = task;
   186  tei.n_elem = n_elem;
   187  tei.slot = slot;
   188  switch (task->task_proto) {
   189  case SAS_PROTOCOL_SSP:
   190  rc = hisi_sas_task_prep_ssp(hisi_hba, &tei, is_tmf, 
tmf);
   191  break;
   192  case SAS_PROTOCOL_SMP:
   193  case SAS_PROTOCOL_SATA:
   194  case SAS_PROTOCOL_STP:
   195  case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
   196  default:
   197  dev_err(dev, "task prep: unknown/unsupported proto 
(0x%x)\n",
   198  task->task_proto);
   199  rc = -EINVAL;
   200  break;
   201  }
   202  
   203  if (rc) {
   204  dev_err(dev, "task prep: rc = 0x%x\n", rc);
   205  if (slot->sge_page)
   206  goto err_out_sge;
   207  goto err_out_command_table;
   208  }
   209  
   210  slot->task = task;
   211  slot->port = tei.port;
   212  task->lldd_task = slot;
   213  list_add_tail(&slot->entry, &tei.port->list);
   214  spin_lock(&task->task_state_lock);
   215  task->task_state_flags |= SAS_TASK

Re: [PATCH 05/25] scsi: hisi_sas: allocate memories and create pools

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test ERROR on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
config: m68k-allmodconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k 

All error/warnings (new ones prefixed by >>):

   drivers/scsi/hisi_sas/hisi_sas_init.c: In function 'hisi_sas_alloc':
>> drivers/scsi/hisi_sas/hisi_sas_init.c:65:2: error: implicit declaration of 
>> function 'dma_pool_create' [-Werror=implicit-function-declaration]
 hisi_hba->status_buffer_pool = dma_pool_create(name,
 ^
>> drivers/scsi/hisi_sas/hisi_sas_init.c:65:31: warning: assignment makes 
>> pointer from integer without a cast
 hisi_hba->status_buffer_pool = dma_pool_create(name,
  ^
   drivers/scsi/hisi_sas/hisi_sas_init.c:73:31: warning: assignment makes 
pointer from integer without a cast
 hisi_hba->command_table_pool = dma_pool_create(name,
  ^
   drivers/scsi/hisi_sas/hisi_sas_init.c:115:26: warning: assignment makes 
pointer from integer without a cast
 hisi_hba->sge_page_pool = dma_pool_create(name, dev,
 ^
   drivers/scsi/hisi_sas/hisi_sas_init.c: In function 'hisi_sas_free':
>> drivers/scsi/hisi_sas/hisi_sas_init.c:159:3: error: implicit declaration of 
>> function 'dma_pool_destroy' [-Werror=implicit-function-declaration]
  dma_pool_destroy(hisi_hba->status_buffer_pool);
  ^
   cc1: some warnings being treated as errors

vim +/dma_pool_create +65 drivers/scsi/hisi_sas/hisi_sas_init.c

59  memset(hisi_hba->complete_hdr[i], 0, s);
60  }
61  
62  sprintf(name, "%s%d", "hisi_sas_status_buffer_pool",
63  hisi_hba->id);
64  s = HISI_SAS_STATUS_BUF_SZ;
  > 65  hisi_hba->status_buffer_pool = dma_pool_create(name,
66 dev, s, 16, 0);
67  if (!hisi_hba->status_buffer_pool)
68  goto err_out;
69  
70  sprintf(name, "%s%d", "hisi_sas_command_table_pool",
71  hisi_hba->id);
72  s = HISI_SAS_COMMAND_TABLE_SZ;
  > 73  hisi_hba->command_table_pool = dma_pool_create(name,
74 dev, s, 16, 0);
75  if (!hisi_hba->command_table_pool)
76  goto err_out;
77  
78  s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct);
79  hisi_hba->itct = dma_alloc_coherent(dev, s, &hisi_hba->itct_dma,
80  GFP_KERNEL);
81  if (!hisi_hba->itct)
82  goto err_out;
83  
84  memset(hisi_hba->itct, 0, s);
85  
86  hisi_hba->slot_info = devm_kcalloc(dev, 
HISI_SAS_COMMAND_ENTRIES,
87 sizeof(struct hisi_sas_slot),
88 GFP_KERNEL);
89  if (!hisi_hba->slot_info)
90  goto err_out;
91  
92  s = HISI_SAS_COMMAND_ENTRIES * sizeof(struct hisi_sas_iost);
93  hisi_hba->iost = dma_alloc_coherent(dev, s, &hisi_hba->iost_dma,
94  GFP_KERNEL);
95  if (!hisi_hba->iost)
96  goto err_out;
97  
98  memset(hisi_hba->iost, 0, s);
99  
   100  s = HISI_SAS_COMMAND_ENTRIES * sizeof(struct 
hisi_sas_breakpoint);
   101  hisi_hba->breakpoint = dma_alloc_coherent(dev, s,
   102  &hisi_hba->breakpoint_dma, GFP_KERNEL);
   103  if (!hisi_hba->breakpoint)
   104  goto err_out;
   105  
   106  memset(hisi_hba->breakpoint, 0, s);
   107  
   108  hisi_hba->slot_index_count = HISI_SAS_COMMAND_ENTRIES;
   109  s = hisi_hba->slot_index_count / sizeof(unsigned long);
   110  hisi_hba->slot_index_tags = devm_kzalloc(dev, s, GFP_KERNEL);
   111  if (!hisi_hba->slot_index_tags)
   112  goto err_out;
   113  
   114  sprintf(name, "%s%d", "hisi_sas_status_sge_pool", hisi_hba->id);
   115  hisi_hba->sge_page_pool = dma_pool_create(name, dev,
   116  sizeof(struct hisi_sas_sg

Re: [lkp] [PATCH 13/25] scsi: hisi_sas: add path from phyup irq to SAS framework

2015-10-12 Thread Fengguang Wu
Hi Julian,

Oops, this is awkward.. I'll check it, thank you for the reminder!

Thanks,
Fengguang

On Tue, Oct 13, 2015 at 11:27:05AM +1100, Julian Calaby wrote:
> Hi kbuild test robot people,
> 
> On Tue, Oct 13, 2015 at 9:03 AM, kbuild test robot  wrote:
> > Hi John,
> >
> > [auto build test WARNING on scsi/for-next -- if it's inappropriate base, 
> > please suggest rules for selecting the more suitable base]
> >
> > url:
> > https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
> > reproduce:
> > # apt-get install sparse
> > make ARCH=x86_64 allmodconfig
> > make C=1 CF=-D__CHECK_ENDIAN__
> >
> >
> > sparse warnings: (new ones prefixed by >>)
> 
> Your script seems to have lost the actual warnings here.
> 
> > Please review and possibly fold the followup patch.
> 
> Thanks,
> 
> -- 
> Julian Calaby
> 
> Email: julian.cal...@gmail.com
> Profile: http://www.google.com/profiles/julian.calaby/
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/25] scsi: hisi_sas: add path from phyup irq to SAS framework

2015-10-12 Thread Julian Calaby
Hi kbuild test robot people,

On Tue, Oct 13, 2015 at 9:03 AM, kbuild test robot  wrote:
> Hi John,
>
> [auto build test WARNING on scsi/for-next -- if it's inappropriate base, 
> please suggest rules for selecting the more suitable base]
>
> url:
> https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
> reproduce:
> # apt-get install sparse
> make ARCH=x86_64 allmodconfig
> make C=1 CF=-D__CHECK_ENDIAN__
>
>
> sparse warnings: (new ones prefixed by >>)

Your script seems to have lost the actual warnings here.

> Please review and possibly fold the followup patch.

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 22/25] scsi: hisi_sas: add tmf methods

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test WARNING on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   drivers/scsi/hisi_sas/hisi_sas_main.c:341:6: sparse: symbol 
'hisi_sas_bytes_dmaed' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_main.c:378:24: sparse: symbol 
'hisi_sas_alloc_dev' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_main.c:396:5: sparse: symbol 
'hisi_sas_dev_found_notify' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_main.c:523:6: sparse: symbol 
'hisi_sas_port_notify_formed' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_main.c:561:6: sparse: symbol 
'hisi_sas_do_release_task' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_main.c:615:5: sparse: symbol 
>> 'hisi_sas_find_dev_phyno' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_main.c:852:52: sparse: incorrect type in 
>> assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_main.c:852:52:expected unsigned short 
[unsigned] [assigned] [usertype] tag_of_task_to_be_managed
   drivers/scsi/hisi_sas/hisi_sas_main.c:852:52:got restricted __le16 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_main.c:1000:52: sparse: incorrect type in 
assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_main.c:1000:52:expected unsigned short 
[unsigned] [assigned] [usertype] tag_of_task_to_be_managed
   drivers/scsi/hisi_sas/hisi_sas_main.c:1000:52:got restricted __le16 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_main.c:448:9: sparse: context imbalance in 
'hisi_sas_dev_found_notify' - different lock contexts for basic block
   drivers/scsi/hisi_sas/hisi_sas_main.c:523:6: sparse: context imbalance in 
'hisi_sas_port_notify_formed' - different lock contexts for basic block

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH] scsi: hisi_sas: hisi_sas_find_dev_phyno() can be static

2015-10-12 Thread kbuild test robot

Signed-off-by: Fengguang Wu 
---
 hisi_sas_main.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 12af29c..a01e8c0 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -612,7 +612,7 @@ int hisi_sas_dev_found(struct domain_device *device)
return hisi_sas_dev_found_notify(device, 1);
 }
 
-int hisi_sas_find_dev_phyno(struct domain_device *device, int *phyno)
+static int hisi_sas_find_dev_phyno(struct domain_device *device, int *phyno)
 {
int i = 0, j = 0, num = 0, n = 0;
struct sas_ha_struct *sha = device->port->ha;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 18/25] scsi: hisi_sas: add dev_gone and port_deformed

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test WARNING on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   drivers/scsi/hisi_sas/hisi_sas_main.c:321:6: sparse: symbol 
'hisi_sas_bytes_dmaed' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_main.c:358:24: sparse: symbol 
'hisi_sas_alloc_dev' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_main.c:376:5: sparse: symbol 
'hisi_sas_dev_found_notify' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_main.c:479:6: sparse: symbol 
'hisi_sas_port_notify_formed' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_main.c:517:6: sparse: symbol 
>> 'hisi_sas_do_release_task' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_main.c:428:9: sparse: context imbalance in 
'hisi_sas_dev_found_notify' - different lock contexts for basic block
   drivers/scsi/hisi_sas/hisi_sas_main.c:479:6: sparse: context imbalance in 
'hisi_sas_port_notify_formed' - different lock contexts for basic block
--
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: incorrect type in 
argument 1 (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26:expected unsigned long 
long [unsigned] [usertype] val
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26:got restricted __le64 
[usertype] sas_addr
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
__le64
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:24: sparse: incorrect type in 
assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:24:expected restricted __le64 
[usertype] sas_addr
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:24:got unsigned long long
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:553:15: sparse: cast from restricted 
__le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:553:13: sparse: incorrect type in 
>> assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:553:13:expected unsigned int 
[unsigned] [usertype] qw0
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:553:13:got restricted __le64 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:761:6: sparse: symbol 
'enable_phy_v1_hw' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1042:36: sparse: cast from restricted 
__le32
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1042:36: sparse: incorrect type in 
initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1042:36:expected unsigned int 
[unsigned] [usertype] dma_err_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1042:36:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1050:33: sparse: cast from restricted 
__le32
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1050:33: sparse: incorrect type in 
initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1050:33:expected unsigned int 
[unsigned] [usertype] trans_tx_fail_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1050:33:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1052:33: sparse: cast from restricted 
__le32
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1052:33: sparse: incorrect type in 
initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1052:33:expected unsigned int 
[unsigned] [usertype] trans_rx_fail_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1052:33:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1456:34: sparse: cast from restricted 
__le32
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1456:32: sparse: incorrect type in 
assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1456:32:expected unsigned int 
[unsigned] [usertype] cmplt_hdr_data
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1456:32:got restricted __le32 
[usertype] 

P

[RFC PATCH] scsi: hisi_sas: hisi_sas_do_release_task() can be static

2015-10-12 Thread kbuild test robot

Signed-off-by: Fengguang Wu 
---
 hisi_sas_main.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 36ef8cd..38f581f 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -514,7 +514,7 @@ void hisi_sas_port_notify_formed(struct asd_sas_phy 
*sas_phy, int lock)
spin_unlock_irqrestore(&hisi_hba->lock, flags);
 }
 
-void hisi_sas_do_release_task(struct hisi_hba *hisi_hba,
+static void hisi_sas_do_release_task(struct hisi_hba *hisi_hba,
int phy_no, struct domain_device *device)
 {
struct hisi_sas_phy *phy;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 16/25] scsi: hisi_sas: add dev_found and port_formed

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test WARNING on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   drivers/scsi/hisi_sas/hisi_sas_main.c:321:6: sparse: symbol 
'hisi_sas_bytes_dmaed' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_main.c:358:24: sparse: symbol 
>> 'hisi_sas_alloc_dev' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_main.c:376:5: sparse: symbol 
>> 'hisi_sas_dev_found_notify' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_main.c:479:6: sparse: symbol 
>> 'hisi_sas_port_notify_formed' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_main.c:428:9: sparse: context imbalance in 
>> 'hisi_sas_dev_found_notify' - different lock contexts for basic block
>> drivers/scsi/hisi_sas/hisi_sas_main.c:479:6: sparse: context imbalance in 
>> 'hisi_sas_port_notify_formed' - different lock contexts for basic block
--
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: incorrect type in 
>> argument 1 (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26:expected unsigned long 
long [unsigned] [usertype] val
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26:got restricted __le64 
[usertype] sas_addr
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:26: sparse: cast from restricted 
>> __le64
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:24: sparse: incorrect type in 
>> assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:24:expected restricted __le64 
[usertype] sas_addr
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:528:24:got unsigned long long
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:733:6: sparse: symbol 
'enable_phy_v1_hw' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1014:36: sparse: cast from restricted 
__le32
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1014:36: sparse: incorrect type in 
initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1014:36:expected unsigned int 
[unsigned] [usertype] dma_err_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1014:36:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1022:33: sparse: cast from restricted 
__le32
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1022:33: sparse: incorrect type in 
initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1022:33:expected unsigned int 
[unsigned] [usertype] trans_tx_fail_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1022:33:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1024:33: sparse: cast from restricted 
__le32
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1024:33: sparse: incorrect type in 
initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1024:33:expected unsigned int 
[unsigned] [usertype] trans_rx_fail_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1024:33:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1120:5: sparse: symbol 
'slot_complete_v1_hw' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1374:34: sparse: cast from restricted 
__le32
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1374:32: sparse: incorrect type in 
assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1374:32:expected unsigned int 
[unsigned] [usertype] cmplt_hdr_data
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1374:32:got restricted __le32 
[usertype] 

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH] scsi: hisi_sas: hisi_sas_alloc_dev() can be static

2015-10-12 Thread kbuild test robot

Signed-off-by: Fengguang Wu 
---
 hisi_sas_main.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 44cb9085..f7ee97a 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -355,7 +355,7 @@ void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int 
phy_no)
sas_ha->notify_port_event(sas_phy, PORTE_BYTES_DMAED);
 }
 
-struct hisi_sas_device *hisi_sas_alloc_dev(struct hisi_hba *hisi_hba)
+static struct hisi_sas_device *hisi_sas_alloc_dev(struct hisi_hba *hisi_hba)
 {
int dev_id;
struct device *dev = &hisi_hba->pdev->dev;
@@ -373,7 +373,7 @@ struct hisi_sas_device *hisi_sas_alloc_dev(struct hisi_hba 
*hisi_hba)
return NULL;
 }
 
-int hisi_sas_dev_found_notify(struct domain_device *device, int lock)
+static int hisi_sas_dev_found_notify(struct domain_device *device, int lock)
 {
unsigned long flags = 0;
int res = 0;
@@ -476,7 +476,7 @@ void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int 
phy_no)
sas_phy->lldd_phy = phy;
 }
 
-void hisi_sas_port_notify_formed(struct asd_sas_phy *sas_phy, int lock)
+static void hisi_sas_port_notify_formed(struct asd_sas_phy *sas_phy, int lock)
 {
struct sas_ha_struct *sas_ha = sas_phy->ha;
struct hisi_hba *hisi_hba = NULL;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 15/25] scsi: hisi_sas: add cq interrupt handler

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test WARNING on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:692:6: sparse: symbol 
'enable_phy_v1_hw' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:973:36: sparse: cast from restricted 
>> __le32
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:973:36: sparse: incorrect type in 
>> initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:973:36:expected unsigned int 
[unsigned] [usertype] dma_err_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:973:36:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:981:33: sparse: cast from restricted 
__le32
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:981:33: sparse: incorrect type in 
>> initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:981:33:expected unsigned int 
[unsigned] [usertype] trans_tx_fail_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:981:33:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:983:33: sparse: cast from restricted 
__le32
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:983:33: sparse: incorrect type in 
>> initializer (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:983:33:expected unsigned int 
[unsigned] [usertype] trans_rx_fail_type
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:983:33:got restricted __le32 
[usertype] 
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1079:5: sparse: symbol 
'slot_complete_v1_hw' was not declared. Should it be static?
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1333:34: sparse: cast from restricted 
__le32
>> drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1333:32: sparse: incorrect type in 
>> assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1333:32:expected unsigned int 
[unsigned] [usertype] cmplt_hdr_data
   drivers/scsi/hisi_sas/hisi_sas_v1_hw.c:1333:32:got restricted __le32 
[usertype] 

vim +973 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c

   967  struct device *dev = &hisi_hba->pdev->dev;
   968  
   969  switch (task->task_proto) {
   970  case SAS_PROTOCOL_SSP:
   971  {
   972  int error = -1;
 > 973  u32 dma_err_type = 
 > cpu_to_le32(err_record->dma_err_type);
   974  u32 dma_tx_err_type = ((dma_err_type &
   975  ERR_HDR_DMA_TX_ERR_TYPE_MSK)) >>
   976  ERR_HDR_DMA_TX_ERR_TYPE_OFF;
   977  u32 dma_rx_err_type = ((dma_err_type &
   978  ERR_HDR_DMA_RX_ERR_TYPE_MSK)) >>
   979  ERR_HDR_DMA_RX_ERR_TYPE_OFF;
   980  u32 trans_tx_fail_type =
 > 981  
 > cpu_to_le32(err_record->trans_tx_fail_type);
   982  u32 trans_rx_fail_type =
 > 983  
 > cpu_to_le32(err_record->trans_rx_fail_type);
   984  
   985  if (dma_tx_err_type) {
   986  /* dma tx err */

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 13/25] scsi: hisi_sas: add path from phyup irq to SAS framework

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test WARNING on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)


Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH] scsi: hisi_sas: hisi_sas_bytes_dmaed() can be static

2015-10-12 Thread kbuild test robot

Signed-off-by: Fengguang Wu 
---
 hisi_sas_main.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 72831db..08b2af8 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -28,7 +28,7 @@ void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
 }
 
 
-void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int phy_no)
+static void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int phy_no)
 {
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
struct asd_sas_phy *sas_phy = &phy->sas_phy;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/25] scsi: hisi_sas: add misc HBA initialization

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test WARNING on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   drivers/scsi/hisi_sas/hisi_sas_init.c:228:5: sparse: symbol 
'hisi_sas_ioremap' was not declared. Should it be static?
>> drivers/scsi/hisi_sas/hisi_sas_init.c:318:47: sparse: incorrect type in 
>> assignment (different base types)
   drivers/scsi/hisi_sas/hisi_sas_init.c:318:47:expected unsigned long long 
[unsigned] [usertype] dev_sas_addr
   drivers/scsi/hisi_sas/hisi_sas_init.c:318:47:got restricted __be64 
[usertype] 

vim +318 drivers/scsi/hisi_sas/hisi_sas_init.c

307b867d John Garry 2015-10-12  222   
hisi_hba->sata_breakpoint_dma);
ac2334d3 John Garry 2015-10-12  223  
ac2334d3 John Garry 2015-10-12  224 if (hisi_hba->wq)
ac2334d3 John Garry 2015-10-12  225 destroy_workqueue(hisi_hba->wq);
307b867d John Garry 2015-10-12  226  }
307b867d John Garry 2015-10-12  227  
2b5563f7 John Garry 2015-10-12 @228  int hisi_sas_ioremap(struct hisi_hba 
*hisi_hba)
2b5563f7 John Garry 2015-10-12  229  {
2b5563f7 John Garry 2015-10-12  230 struct platform_device *pdev = 
hisi_hba->pdev;
2b5563f7 John Garry 2015-10-12  231 struct device *dev = &pdev->dev;
2b5563f7 John Garry 2015-10-12  232 struct resource *res;
2b5563f7 John Garry 2015-10-12  233  
2b5563f7 John Garry 2015-10-12  234 res = platform_get_resource(pdev, 
IORESOURCE_MEM, 0);
2b5563f7 John Garry 2015-10-12  235 hisi_hba->regs = devm_ioremap(dev,
2b5563f7 John Garry 2015-10-12  236   
res->start,
2b5563f7 John Garry 2015-10-12  237   
resource_size(res));
2b5563f7 John Garry 2015-10-12  238 if (!hisi_hba->regs)
2b5563f7 John Garry 2015-10-12  239 return -ENOMEM;
2b5563f7 John Garry 2015-10-12  240  
2b5563f7 John Garry 2015-10-12  241 res = platform_get_resource(pdev, 
IORESOURCE_MEM, 1);
2b5563f7 John Garry 2015-10-12  242 hisi_hba->ctrl_regs = devm_ioremap(dev,
2b5563f7 John Garry 2015-10-12  243
res->start,
2b5563f7 John Garry 2015-10-12  244
resource_size(res));
2b5563f7 John Garry 2015-10-12  245 if (!hisi_hba->ctrl_regs)
2b5563f7 John Garry 2015-10-12  246 return -ENOMEM;
2b5563f7 John Garry 2015-10-12  247  
2b5563f7 John Garry 2015-10-12  248 return 0;
2b5563f7 John Garry 2015-10-12  249  }
28e5387c John Garry 2015-10-12  250  
28e5387c John Garry 2015-10-12  251  static const struct of_device_id 
sas_of_match[] = {
28e5387c John Garry 2015-10-12  252 { .compatible = 
"hisilicon,sas-controller-v1",},
28e5387c John Garry 2015-10-12  253 {},
28e5387c John Garry 2015-10-12  254  };
28e5387c John Garry 2015-10-12  255  MODULE_DEVICE_TABLE(of, sas_of_match);
b94d2f2e John Garry 2015-10-12  256  
b94d2f2e John Garry 2015-10-12  257  static struct hisi_hba *hisi_sas_hba_alloc(
b94d2f2e John Garry 2015-10-12  258 struct platform_device 
*pdev,
b94d2f2e John Garry 2015-10-12  259 struct Scsi_Host *shost,
b94d2f2e John Garry 2015-10-12  260 struct device_node *np)
b94d2f2e John Garry 2015-10-12  261  {
b94d2f2e John Garry 2015-10-12  262 int interrupt_count, interrupt_cells;
b94d2f2e John Garry 2015-10-12  263 struct hisi_hba *hisi_hba;
b94d2f2e John Garry 2015-10-12  264  
b94d2f2e John Garry 2015-10-12  265 hisi_hba = devm_kzalloc(&pdev->dev, 
sizeof(*hisi_hba), GFP_KERNEL);
b94d2f2e John Garry 2015-10-12  266 if (!hisi_hba)
b94d2f2e John Garry 2015-10-12  267 goto err_out;
b94d2f2e John Garry 2015-10-12  268  
b94d2f2e John Garry 2015-10-12  269 hisi_hba->pdev = pdev;
307b867d John Garry 2015-10-12  270  
ac2334d3 John Garry 2015-10-12  271 init_timer(&hisi_hba->timer);
ac2334d3 John Garry 2015-10-12  272  
307b867d John Garry 2015-10-12  273 if (of_property_read_u32(np, 
"phy-count", &hisi_hba->n_phy))
307b867d John Garry 2015-10-12  274 goto err_out;
307b867d John Garry 2015-10-12  275  
307b867d John Garry 2015-10-12  276 if (of_property_read_u32(np, 
"queue-count", &hisi_hba->queue_count))
307b867d John Garry 2015-10-12  277 goto err_out;
307b867d John Garry 2015-10-12  278  
307b867d John Garry 2015-10-12  279 if (of_property_read_u32(np, 
"controller-id", &hisi_hba->id))
307b867d John Garry 2015-10-12  280 goto err_out;
307b867d John Garry 2015-10-12  281  
307b867d John Garry 2015-10-12 

Re: [PATCH, RFC] blk-mq: use a delayed work item for timeouts

2015-10-12 Thread Jens Axboe

On 10/12/2015 02:22 PM, Christoph Hellwig wrote:

On Mon, Oct 12, 2015 at 02:08:04PM -0600, Jens Axboe wrote:

No that's definitely fine with me, imho most error handling callbacks
should be in process context for ease of use in the driver.


Took a closer look. The patch looks incomplete. The hot path for blk-mq is
blk_add_timer(), looks like you left that one alone in the conversion?


Oh, damn.  I had that part in my initial version that also crudely
converted the old request code and dropped a bit too much.  That should
defintively do the queue_deayed_work.


Yep


Might be easier to just leave the timer alone, and if it actually fires
_and_ we have to do something, punt to a workqueue instead of invoking the
timeout handler directly.


queue_delayed_work just assigns two additional fields, then sets
timer->experies and does an add_timer.  So it's the generic implementation
of your above scheme.  I'd much rather use the generic version if
possible instead of trying to recreate it.


I agree, converting to delayed work in general is the cleaner solution. 
The hot path is really NOT doing anything at all, that's the usual path. 
If it isn't, then we've screwed up. And the conversion to 
delayed_work_pending() from timer_pending() looks fine as well, that's 
another important piece.


--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH, RFC] blk-mq: use a delayed work item for timeouts

2015-10-12 Thread Christoph Hellwig
On Mon, Oct 12, 2015 at 02:08:04PM -0600, Jens Axboe wrote:
>> No that's definitely fine with me, imho most error handling callbacks
>> should be in process context for ease of use in the driver.
>
> Took a closer look. The patch looks incomplete. The hot path for blk-mq is 
> blk_add_timer(), looks like you left that one alone in the conversion?

Oh, damn.  I had that part in my initial version that also crudely
converted the old request code and dropped a bit too much.  That should
defintively do the queue_deayed_work.

> Might be easier to just leave the timer alone, and if it actually fires 
> _and_ we have to do something, punt to a workqueue instead of invoking the 
> timeout handler directly.

queue_delayed_work just assigns two additional fields, then sets
timer->experies and does an add_timer.  So it's the generic implementation
of your above scheme.  I'd much rather use the generic version if
possible instead of trying to recreate it.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH, RFC] blk-mq: use a delayed work item for timeouts

2015-10-12 Thread Jens Axboe

On 10/12/2015 01:34 PM, Jens Axboe wrote:

On 10/12/2015 01:29 PM, Christoph Hellwig wrote:

For some pending NVMe work I'd really love to be able to get my timeouts
from process context.  So far it seems only SCSI and NVMe use the blk-mq
timeout handler, and both don't seem to be particularly excited about
being called from time context.  Does anyone have an objection against
the patch below that switches it to use a delayed work item?  I could
make use of this quickly for NVMe, but for SCSI we still have to deal
with the old request code which can't be switched to a delayed work
as easily.


No that's definitely fine with me, imho most error handling callbacks
should be in process context for ease of use in the driver.


Took a closer look. The patch looks incomplete. The hot path for blk-mq 
is blk_add_timer(), looks like you left that one alone in the conversion?


Might be easier to just leave the timer alone, and if it actually fires 
_and_ we have to do something, punt to a workqueue instead of invoking 
the timeout handler directly.


--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bugs in multipath scsi in 4.3-rc2

2015-10-12 Thread Christoph Hellwig
On Mon, Oct 12, 2015 at 03:29:45PM -0400, Mike Snitzer wrote:
> What may be getting lost during this discussion is that historically
> it has been important to be able to attach the scsi_dh during the SCSI
> scan.  As the scsi_dh alters the SCSI midlayer's sense code processing
> (via callout to the attached scsi_dh).  And this altered SCSI sense
> code handling amounts to the difference between a successful/quick
> boot versus hugely delayed and ultimately error-prone boot on systems
> with many LUNs that have multiple paths.
> 
> So that is why either of these solutions were deployed:
> 1) in RHEL6 we'd require dracut to preload the scsi_dh modules early
> in loading the initramfs
> 2) in RHEL7 all scsi_dh modules _are_ builtin
> 
> Both achieve the goal of having all required scsi_dh available during SCSI 
> scan.

Yes, and both are workarounds.  I tried to implement this properly,
but due to async probing it doesn't actually work.  Given the statement
from Tejun I don't really see how to ever get it to work as long as
we use async probing and the module loading code isn't safe to call
from the async probe path unfortunately.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH, RFC] blk-mq: use a delayed work item for timeouts

2015-10-12 Thread Jens Axboe

On 10/12/2015 01:29 PM, Christoph Hellwig wrote:

For some pending NVMe work I'd really love to be able to get my timeouts
from process context.  So far it seems only SCSI and NVMe use the blk-mq
timeout handler, and both don't seem to be particularly excited about
being called from time context.  Does anyone have an objection against
the patch below that switches it to use a delayed work item?  I could
make use of this quickly for NVMe, but for SCSI we still have to deal
with the old request code which can't be switched to a delayed work
as easily.


No that's definitely fine with me, imho most error handling callbacks 
should be in process context for ease of use in the driver.



--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH, RFC] blk-mq: use a delayed work item for timeouts

2015-10-12 Thread Christoph Hellwig
For some pending NVMe work I'd really love to be able to get my timeouts
from process context.  So far it seems only SCSI and NVMe use the blk-mq
timeout handler, and both don't seem to be particularly excited about
being called from time context.  Does anyone have an objection against
the patch below that switches it to use a delayed work item?  I could
make use of this quickly for NVMe, but for SCSI we still have to deal
with the old request code which can't be switched to a delayed work
as easily.
---
 block/blk-mq.c | 11 ++-
 include/linux/blkdev.h |  5 -
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index d921cd5..a7ae387 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -635,9 +635,10 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx 
*hctx,
}
 }
 
-static void blk_mq_rq_timer(unsigned long priv)
+static void blk_mq_rq_timer_work(struct work_struct *work)
 {
-   struct request_queue *q = (struct request_queue *)priv;
+   struct request_queue *q =
+   container_of(work, struct request_queue, timeout_work.work);
struct blk_mq_timeout_data data = {
.next   = 0,
.next_set   = 0,
@@ -648,7 +649,7 @@ static void blk_mq_rq_timer(unsigned long priv)
 
if (data.next_set) {
data.next = blk_rq_timeout(round_jiffies_up(data.next));
-   mod_timer(&q->timeout, data.next);
+   mod_delayed_work(system_wq, &q->timeout_work, data.next);
} else {
struct blk_mq_hw_ctx *hctx;
 
@@ -2008,7 +2009,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct 
blk_mq_tag_set *set,
PERCPU_REF_INIT_ATOMIC, GFP_KERNEL))
goto err_hctxs;
 
-   setup_timer(&q->timeout, blk_mq_rq_timer, (unsigned long) q);
+   INIT_DELAYED_WORK(&q->timeout_work, blk_mq_rq_timer_work);
blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30 * HZ);
 
q->nr_queues = nr_cpu_ids;
@@ -2173,7 +2174,7 @@ static int blk_mq_queue_reinit_notify(struct 
notifier_block *nb,
 * timeout handler can't touch hw queue during the
 * reinitialization
 */
-   del_timer_sync(&q->timeout);
+   cancel_delayed_work_sync(&q->timeout_work);
}
 
list_for_each_entry(q, &all_q_list, all_q_node)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 19c2e94..ecce48f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -401,7 +401,10 @@ struct request_queue {
unsigned intrequest_fn_active;
 
unsigned intrq_timeout;
-   struct timer_list   timeout;
+   union {
+   struct timer_list   timeout;/* legacy */
+   struct delayed_work timeout_work;   /* blk-mq */
+   };
struct list_headtimeout_list;
 
struct list_headicq_list;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bugs in multipath scsi in 4.3-rc2

2015-10-12 Thread Mike Snitzer
On Mon, Oct 12, 2015 at 10:39 AM, Christoph Hellwig  wrote:
> On Mon, Oct 12, 2015 at 02:45:38PM +0200, Hannes Reinecke wrote:
>> You cannot easily use the driver model here as the scsi_device is
>> already (potentially) bound to the ULDs.
>> If you were to go with the driver model you'd have to introduce
>> another sub device between scsi_target and scsi_device.
>
> You can have two struct devices in struct scsi_device, while it's
> not pretty there are plenty of example all over the kernel with
> multiple devices in a single containing structure.
>
>> Actually I have been thinking that, as it might make my life for the
>> ALUA handler easier. However, this would be quite a largish redesign
>> of the current handler infrastructure, pushing out my ALUA handler
>> update even more.
>> So I'd like to have the ALUA changes ironed out first and merged,
>> and then work on a redesigned device handler infrastructure.
>
> Fine with me.  As mentioned before we've never supported autoloading
> the device handler modules at boot time - we only ever loaded them when
> explicitly attaching them through device mapper.  Waiting another
> release or maybe two to finally get there isn't the end of the world.

What may be getting lost during this discussion is that historically
it has been important to be able to attach the scsi_dh during the SCSI
scan.  As the scsi_dh alters the SCSI midlayer's sense code processing
(via callout to the attached scsi_dh).  And this altered SCSI sense
code handling amounts to the difference between a successful/quick
boot versus hugely delayed and ultimately error-prone boot on systems
with many LUNs that have multiple paths.

So that is why either of these solutions were deployed:
1) in RHEL6 we'd require dracut to preload the scsi_dh modules early
in loading the initramfs
2) in RHEL7 all scsi_dh modules _are_ builtin

Both achieve the goal of having all required scsi_dh available during SCSI scan.

Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 12/25] scsi: hisi_sas: add v1 HW initialisation code

2015-10-12 Thread Arnd Bergmann
On Monday 12 October 2015 23:20:24 John Garry wrote:
> @@ -387,6 +392,21 @@ static int hisi_sas_probe(struct platform_device *pdev)
> }
>  
> hisi_sas_init_add(hisi_hba);
> +
> +   rc = hw_init_v1_hw(hisi_hba);
> +   if (rc)
> +   goto err_out_ha;
> +
> +   rc = interrupt_init_v1_hw(hisi_hba);
> +   if (rc)
> +   goto err_out_ha;
> +
> +   rc = interrupt_openall_v1_hw(hisi_hba);
> +   if (rc)
> +   goto err_out_ha;
> +
> +   phys_init_v1_hw(hisi_hba);
> +
> rc = scsi_add_host(shost, &pdev->dev);
> if (rc)
> goto err_out_ha;
> 

As the probe function matches against the "hisilicon,sas-controller-v1"
compatible string and contains mostly code that is specific to v1, I
think it would be cleaner to move that to the hisi_sas_v1_hw.c as well
and make the functions above static but make the common functions
called here (hisi_sas_init_add etc) global.

That would also include the hisi_sas_driver structure.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] lpfc: fix memory leak and NULL dereference

2015-10-12 Thread James Smart

Looks Good - Thank you Sudip.

Reviewed-by: James Smart 

-- james s


On 9/23/2015 6:32 AM, Sudip Mukherjee wrote:

kmalloc() can return NULL and without checking we were dereferencing it.
Moreover if kmalloc succeeds but the function fails in other parts then
we were returning the error code but we missed freeing lcb_context.
While at it fixed one related checkpatch warning.

Signed-off-by: Sudip Mukherjee 
---

I am not exactly sure if LSRJT_UNABLE_TPC is the right error code here.
But that was my best guess.

  drivers/scsi/lpfc/lpfc_els.c | 8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 36bf58b..a27efd9 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5209,7 +5209,6 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
lpfc_iocbq *cmdiocb,
rjt_err = LSRJT_CMD_UNSUPPORTED;
goto rjt;
}
-   lcb_context = kmalloc(sizeof(struct lpfc_lcb_context), GFP_KERNEL);
  
  	if (phba->hba_flag & HBA_FCOE_MODE) {

rjt_err = LSRJT_CMD_UNSUPPORTED;
@@ -5240,6 +5239,12 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
lpfc_iocbq *cmdiocb,
goto rjt;
}
  
+	lcb_context = kmalloc(sizeof(*lcb_context), GFP_KERNEL);

+   if (!lcb_context) {
+   rjt_err = LSRJT_UNABLE_TPC;
+   goto rjt;
+   }
+
state = (beacon->lcb_sub_command == LPFC_LCB_ON) ? 1 : 0;
lcb_context->sub_command = beacon->lcb_sub_command;
lcb_context->type = beacon->lcb_type;
@@ -5250,6 +5255,7 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
lpfc_iocbq *cmdiocb,
if (lpfc_sli4_set_beacon(vport, lcb_context, state)) {
lpfc_printf_vlog(ndlp->vport, KERN_ERR,
 LOG_ELS, "0193 failed to send mail box");
+   kfree(lcb_context);
lpfc_nlp_put(ndlp);
rjt_err = LSRJT_UNABLE_TPC;
goto rjt;


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/25] scsi: hisi_sas: add ioremap for device HW

2015-10-12 Thread kbuild test robot
Hi John,

[auto build test WARNING on scsi/for-next -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/John-Garry/HiSilicon-SAS-driver/20151012-231929
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/scsi/hisi_sas/hisi_sas_init.c:198:5: sparse: symbol 
>> 'hisi_sas_ioremap' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH] scsi: hisi_sas: hisi_sas_ioremap() can be static

2015-10-12 Thread kbuild test robot

Signed-off-by: Fengguang Wu 
---
 hisi_sas_init.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index 8f1e856..066c339 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -195,7 +195,7 @@ static void hisi_sas_free(struct hisi_hba *hisi_hba)
  hisi_hba->sata_breakpoint_dma);
 }
 
-int hisi_sas_ioremap(struct hisi_hba *hisi_hba)
+static int hisi_sas_ioremap(struct hisi_hba *hisi_hba)
 {
struct platform_device *pdev = hisi_hba->pdev;
struct device *dev = &pdev->dev;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: advansys needs ISA dma api for ISA support

2015-10-12 Thread Arnd Bergmann
On Monday 12 October 2015 08:28:01 James Bottomley wrote:
> > 
> > diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
> > index d2f480b04a52..d4aa6a1a806c 100644
> > --- a/drivers/scsi/Kconfig
> > +++ b/drivers/scsi/Kconfig
> > @@ -499,6 +499,7 @@ config SCSI_ADVANSYS
> >   tristate "AdvanSys SCSI support"
> >   depends on SCSI
> >   depends on ISA || EISA || PCI
> > + depends on ISA_DMA_API || !ISA
> >   help
> > This is a driver for all SCSI host adapters manufactured by
> > AdvanSys. It is documented in the kernel source in
> 
> This fix looks wrong.  the request_dma code is confined within an #ifdef
> CONFIG_ISA section but the advansys doesn't actually require an ISA DMA
> channel to function, so you're saying there are systems with ISA but
> without request_dma()?

Yes. Specifically, the ARM EBSA110 and SA1100 platforms can have some
PIO based ISA devices, but they have nothing close enough to an i8237
to support the request_dma interface.

> If so I think we leave the depends alone and try to bring the board up
> in NO_ISA_DMA mode.

Ok

>  That means the narrowboard check should be gated by
> CONFIG_ISA_DMA_API ... do we also have to gate free_dma as well?

Yes. A few more as well, as we also don't want to do inb/outb
instructions to a DMA controller that is not there.

I've compile-tested the patch below.

Arnd

8<---
>From 67fed3da5dd65abf5e4d01d8731c5217eb823fdb Mon Sep 17 00:00:00 2001
From: Arnd Bergmann 
Date: Sat, 10 Oct 2015 21:13:29 +0200
Subject: [PATCH] scsi: advansys: fix build without ISA DMA API

The advansys drvier uses the request_dma function that is used on ISA
machines for the internal DMA controller, which causes build errors
on platforms that have ISA slots but do not provide the ISA DMA API:

drivers/scsi/advansys.c: In function 'advansys_board_found':
drivers/scsi/advansys.c:11300:10: error: implicit declaration of function 
'request_dma' [-Werror=implicit-function-declaration]

The problem now showed up in ARM randconfig builds after commit
6571fb3f8b7f ("advansys: Update to version 3.5 and remove compilation
warning") made it possible to build on platforms that have neither
VIRT_TO_BUS nor ISA_DMA_API but that do have ISA.

This changes the existing #ifdefs in the driver to check for both
CONFIG_ISA and CONFIG_ISA_DMA_API where appropriate. It should
still be possible to use the driver in PIO mode with ISA when
DMA is not available.

Signed-off-by: Arnd Bergmann 

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 1c1cd657c380..9f8aae40dcc8 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2883,9 +2883,9 @@ static void asc_prt_asc_board_eeprom(struct seq_file *m, 
struct Scsi_Host *shost
ASC_DVC_VAR *asc_dvc_varp;
ASCEEP_CONFIG *ep;
int i;
-#ifdef CONFIG_ISA
+#if defined(CONFIG_ISA) && defined(CONFIG_ISA_DMA_API)
int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
-#endif /* CONFIG_ISA */
+#endif /* ISA */
uchar serialstr[13];
 
asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
@@ -2937,13 +2937,13 @@ static void asc_prt_asc_board_eeprom(struct seq_file 
*m, struct Scsi_Host *shost
   (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
seq_putc(m, '\n');
 
-#ifdef CONFIG_ISA
+#if defined(CONFIG_ISA) && defined(CONFIG_ISA_DMA_API)
if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
seq_printf(m,
   " Host ISA DMA speed:   %d MB/S\n",
   isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
}
-#endif /* CONFIG_ISA */
+#endif /* ISA */
 }
 
 /*
@@ -8664,7 +8664,7 @@ static unsigned char AscGetChipVersion(PortAddr iop_base,
return AscGetChipVerNo(iop_base);
 }
 
-#ifdef CONFIG_ISA
+#if defined(CONFIG_ISA) && defined(CONFIG_ISA_DMA_API)
 static void AscEnableIsaDma(uchar dma_channel)
 {
if (dma_channel < 4) {
@@ -8675,7 +8675,7 @@ static void AscEnableIsaDma(uchar dma_channel)
outp(0x00D4, (ushort)(dma_channel - 4));
}
 }
-#endif /* CONFIG_ISA */
+#endif /* ISA */
 
 static int AscStopQueueExe(PortAddr iop_base)
 {
@@ -8704,7 +8704,7 @@ static unsigned int AscGetMaxDmaCount(ushort bus_type)
return ASC_MAX_PCI_DMA_COUNT;
 }
 
-#ifdef CONFIG_ISA
+#if defined(CONFIG_ISA) && defined(CONFIG_ISA_DMA_API)
 static ushort AscGetIsaDmaChannel(PortAddr iop_base)
 {
ushort channel;
@@ -8754,7 +8754,7 @@ static uchar AscSetIsaDmaSpeed(PortAddr iop_base, uchar 
speed_value)
AscSetBank(iop_base, 0);
return AscGetIsaDmaSpeed(iop_base);
 }
-#endif /* CONFIG_ISA */
+#endif /* ISA */
 
 static void AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
 {
@@ -8821,16 +8821,18 @@ static void AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
}
 
asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
-#ifdef CONFIG_ISA
+#if defined(CONFIG_ISA)
if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
if (chip

Re: [PATCH] scsi: advansys needs ISA dma api for ISA support

2015-10-12 Thread James Bottomley
On Mon, 2015-10-12 at 17:10 +0200, Arnd Bergmann wrote:
> The advansys drvier uses the request_dma function that is used on ISA
> machines for the internal DMA controller, which causes build errors
> on platforms that have ISA slots but do not provide the ISA DMA API:
> 
> drivers/scsi/advansys.c: In function 'advansys_board_found':
> drivers/scsi/advansys.c:11300:10: error: implicit declaration of function 
> 'request_dma' [-Werror=implicit-function-declaration]
> 
> The problem now showed up in ARM randconfig builds after commit
> 6571fb3f8b7f ("advansys: Update to version 3.5 and remove compilation
> warning") made it possible to build on platforms that have neither
> VIRT_TO_BUS nor ISA_DMA_API but that do have ISA.
> 
> This adds the missing dependency.
> 
> Signed-off-by: Arnd Bergmann 
> 
> diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
> index d2f480b04a52..d4aa6a1a806c 100644
> --- a/drivers/scsi/Kconfig
> +++ b/drivers/scsi/Kconfig
> @@ -499,6 +499,7 @@ config SCSI_ADVANSYS
>   tristate "AdvanSys SCSI support"
>   depends on SCSI
>   depends on ISA || EISA || PCI
> + depends on ISA_DMA_API || !ISA
>   help
> This is a driver for all SCSI host adapters manufactured by
> AdvanSys. It is documented in the kernel source in

This fix looks wrong.  the request_dma code is confined within an #ifdef
CONFIG_ISA section but the advansys doesn't actually require an ISA DMA
channel to function, so you're saying there are systems with ISA but
without request_dma()?

If so I think we leave the depends alone and try to bring the board up
in NO_ISA_DMA mode.  That means the narrowboard check should be gated by
CONFIG_ISA_DMA_API ... do we also have to gate free_dma as well?

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/25] scsi: hisi_sas: add cq structure initialization

2015-10-12 Thread John Garry
Each completion queue has a structure. This is mainly for
passing to irq handler so we know which queue the irq occured
on.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h  | 6 ++
 drivers/scsi/hisi_sas/hisi_sas_init.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 5f72d98..6c5d22a 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -44,6 +44,10 @@ struct hisi_sas_port {
struct asd_sas_port sas_port;
 };
 
+struct hisi_sas_cq {
+   struct hisi_hba *hisi_hba;
+   int id;
+};
 
 struct hisi_sas_slot {
struct list_head entry;
@@ -92,6 +96,8 @@ struct hisi_hba {
/* SCSI/SAS glue */
struct sas_ha_struct sha;
struct Scsi_Host *shost;
+
+   struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES];
struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS];
struct hisi_sas_port port[HISI_SAS_MAX_PHYS];
int id;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index 8f1e856..44fc524 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -42,6 +42,12 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct 
Scsi_Host *shost)
struct device *dev = &hisi_hba->pdev->dev;
 
for (i = 0; i < hisi_hba->queue_count; i++) {
+   struct hisi_sas_cq *cq = &hisi_hba->cq[i];
+
+   /* Completion queue structure */
+   cq->id = i;
+   cq->hisi_hba = hisi_hba;
+
/* Delivery queue */
s = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS;
hisi_hba->cmd_hdr[i] = dma_alloc_coherent(dev, s,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/25] scsi: hisi_sas: allocate memories and create pools

2015-10-12 Thread Arnd Bergmann
On Monday 12 October 2015 23:20:17 John Garry wrote:
> +   interrupt_count = of_property_count_u32_elems(np, "interrupts");
> +   if (interrupt_count < 0)
> +   goto err_out;
> +
> +   if (of_property_read_u32(np, "#interrupt-cells", &interrupt_cells))
> +   goto err_out;
> +
> +   hisi_hba->int_names = devm_kcalloc(&pdev->dev,
> +  interrupt_count / interrupt_cells,
> +  HISI_SAS_NAME_LEN,
> +  GFP_KERNEL);
> 

This computation looks wrong: the "interrupts" property refers to interrupts
that are referenced by this node and provided by an interrupt-controller,
while the "#interrupt-cells" property refers to interrupts provided by
this node. They don't need to have any relation.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/25] scsi: hisi_sas: allocate memories and create pools

2015-10-12 Thread John Garry
Allocate DMA and non-DMA memories for the controller. Also
create DMA pools.

These include:
- Delivery queues
- Completion queues
- Command status buffer
- Command table
- ITCT (For device context)
- Host slot info
- IO status
- Breakpoint
- host slot indexing
- SG data
- FIS
- interrupts names

The device tree must be examined for relevant fields.

Also set controller id.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h  | 204 ++
 drivers/scsi/hisi_sas/hisi_sas_init.c | 191 ++-
 2 files changed, 394 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 1a90b54..2c15036 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -22,10 +22,18 @@
 #define DRV_VERSION "v1.0"
 
 #define HISI_SAS_MAX_PHYS  9
+#define HISI_SAS_MAX_QUEUES32
+#define HISI_SAS_QUEUE_SLOTS 512
 #define HISI_SAS_MAX_ITCT_ENTRIES 4096
 #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES
 #define HISI_SAS_COMMAND_ENTRIES 8192
 
+#define HISI_SAS_STATUS_BUF_SZ \
+   (sizeof(struct hisi_sas_err_record) + 1024)
+#define HISI_SAS_COMMAND_TABLE_SZ \
+   (((sizeof(union hisi_sas_command_table)+3)/4)*4)
+
+#define HISI_SAS_NAME_LEN 32
 
 struct hisi_sas_phy {
struct hisi_sas_port*port;
@@ -36,6 +44,26 @@ struct hisi_sas_port {
struct asd_sas_port sas_port;
 };
 
+
+struct hisi_sas_slot {
+   struct list_head entry;
+   struct sas_task *task;
+   struct hisi_sas_port*port;
+   u64 n_elem;
+   int dlvry_queue;
+   int dlvry_queue_slot;
+   int cmplt_queue;
+   int cmplt_queue_slot;
+   int idx;
+   void*cmd_hdr;
+   dma_addr_t cmd_hdr_dma;
+   void*status_buffer;
+   dma_addr_t status_buffer_dma;
+   void *command_table;
+   dma_addr_t command_table_dma;
+   struct hisi_sas_sge_page *sge_page;
+   dma_addr_t sge_page_dma;
+};
 struct hisi_hba {
spinlock_t  lock;
 
@@ -44,13 +72,189 @@ struct hisi_hba {
 
u8 sas_addr[SAS_ADDR_SIZE];
 
+   struct hisi_sas_cmd_hdr *cmd_hdr[HISI_SAS_MAX_QUEUES];
+   dma_addr_t  cmd_hdr_dma[HISI_SAS_MAX_QUEUES];
+   struct hisi_sas_complete_hdr*complete_hdr[HISI_SAS_MAX_QUEUES];
+   dma_addr_t  complete_hdr_dma[HISI_SAS_MAX_QUEUES];
+
+   struct hisi_sas_initial_fis *initial_fis;
+   dma_addr_t  initial_fis_dma;
+
int n_phy;
+
+   int slot_index_count;
+   unsigned long *slot_index_tags;
+
+   struct dma_pool *sge_page_pool;
+
/* SCSI/SAS glue */
struct sas_ha_struct sha;
struct Scsi_Host *shost;
struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS];
struct hisi_sas_port port[HISI_SAS_MAX_PHYS];
+   int id;
+   int queue_count;
+   char*int_names;
+   struct dma_pool *command_table_pool;
+   struct dma_pool *status_buffer_pool;
+   struct hisi_sas_itct *itct;
+   dma_addr_t itct_dma;
+   struct hisi_sas_iost *iost;
+   dma_addr_t iost_dma;
+   struct hisi_sas_breakpoint *breakpoint;
+   dma_addr_t breakpoint_dma;
+   struct hisi_sas_breakpoint *sata_breakpoint;
+   dma_addr_t sata_breakpoint_dma;
+   struct hisi_sas_slot*slot_info;
+};
+
+/* Generic HW DMA host memory structures */
+/* Delivery queue header */
+struct hisi_sas_cmd_hdr {
+   /* dw0 */
+   __le32 dw0;
+
+   /* dw1 */
+   __le32 dw1;
+
+   /* dw2 */
+   __le32 dw2;
+
+   /* dw3 */
+   __le32 transfer_tags;
+
+   /* dw4 */
+   __le32 data_transfer_len;
+
+   /* dw5 */
+   __le32 first_burst_num;
+
+   /* dw6 */
+   __le32 sg_len;
+
+   /* dw7 */
+   __le32 dw7;
+
+   /* dw8 */
+   __le32 cmd_table_addr_lo;
+
+   /* dw9 */
+   __le32 cmd_table_addr_hi;
+
+   /* dw10 */
+   __le32 sts_buffer_addr_lo;
+
+   /* dw11 */
+   __le32 sts_buffer_addr_hi;
+
+   /* dw12 */
+   __le32 prd_table_addr_lo;
+
+   /* dw13 */
+   __le32 prd_table_addr_hi;
+
+   /* dw14 */
+   __le32 dif_prd_table_addr_lo;
+
+   /* dw15 */
+   __le32 dif_prd_table_addr_hi;
+};
+
+/* Completion queue header */
+struct hisi_sas_complete_hdr {
+   __le32 data;
+};
+
+struct hisi_sas_itct {
+   __le64 qw0;
+   __le64 sas_addr;
+   __le64 qw2;
+   __le64 qw3;
+   __le64 qw4;
+   __le64 qw_sata_ncq0_3;
+   __le64 qw_sata_ncq7_4;
+   __le64 qw_sata_ncq11_8;
+   __le64 qw_sata_ncq15_12;
+   __le64 qw_sata_ncq19_16;
+   __le64 qw_sata_ncq23_20;
+   __le64 qw_sata_ncq27_24;
+   __le64 qw_sata_ncq31_28;
+   __le64 qw_non_ncq_iptt;
+   __le64 qw_rsvd0;
+   __le64 qw_rsvd1;
+};
+
+struct hisi_sas_iost {
+   __le64 qw0;
+   __le64 qw1;
+   __le64 qw2;
+   __le64 qw3;
+};
+
+struct h

Re: [PATCH v3] scsi: report 'INQUIRY result too short' once per host

2015-10-12 Thread Vitaly Kuznetsov
Hannes Reinecke  writes:

> On 10/08/2015 06:54 PM, Vitaly Kuznetsov wrote:
>> Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
>> SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
>> least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
>> INQUIRY result too short (5), using 36' messages on console. This can be
>> problematic for slow consoles. Introduce short_inquiry flag in struct
>> Scsi_Host to print the message once per host.
>> 
>> Signed-off-by: Vitaly Kuznetsov 
>> ---
>> Changes since v2:
>> - This is a successor of previously sent (and still not merged) "scsi:
>>   introduce short_inquiry flag for broken host adapters" patch. I'm not
>>   particularly sure which solution is better but I'm leaning towards this
>>   one as it doesn't require changes to adapter drivers.
>> ---
>>  drivers/scsi/scsi_scan.c | 9 ++---
>>  include/scsi/scsi_host.h | 3 +++
>>  2 files changed, 9 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>> index f9f3f82..cd347e4 100644
>> --- a/drivers/scsi/scsi_scan.c
>> +++ b/drivers/scsi/scsi_scan.c
>> @@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, 
>> unsigned char *inq_result,
>>   * strings.
>>   */
>>  if (sdev->inquiry_len < 36) {
>> -sdev_printk(KERN_INFO, sdev,
>> -"scsi scan: INQUIRY result too short (%d),"
>> -" using 36\n", sdev->inquiry_len);
>> +if (!sdev->host->short_inquiry) {
>> +shost_printk(KERN_INFO, sdev->host,
>> +"scsi scan: INQUIRY result too short (%d),"
>> +" using 36\n", sdev->inquiry_len);
>> +sdev->host->short_inquiry = 1;
>> +}
>>  sdev->inquiry_len = 36;
>>  }
>>  
> At least you need to check if you've received any valid data here;
> 'INQUIRY result too short' is also a common error if the interrupt
> is hosed when trying to access the device.
> So please check for 'inquiry_len > 4' before setting 'short_inquiry'.

Currently we proceed even with a shorter reply... Should we abort the
scan (and return -EOI?) in case we got inquiry_len <= 4?

Thanks,

-- 
  Vitaly
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/25] scsi: hisi_sas: add ioremap for device HW

2015-10-12 Thread Arnd Bergmann
On Monday 12 October 2015 23:20:19 John Garry wrote:
> +int hisi_sas_ioremap(struct hisi_hba *hisi_hba)
> +{
> +   struct platform_device *pdev = hisi_hba->pdev;
> +   struct device *dev = &pdev->dev;
> +   struct resource *res;
> +
> +   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +   hisi_hba->regs = devm_ioremap(dev,
> + res->start,
> + resource_size(res));
> +   if (!hisi_hba->regs)
> +   return -ENOMEM;
> +
> +   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> +   hisi_hba->ctrl_regs = devm_ioremap(dev,
> +  res->start,
> +  resource_size(res));
> +   if (!hisi_hba->ctrl_regs)
> +   return -ENOMEM;
> +
> +   return 0;
> +}
>  
>  static const struct of_device_id sas_of_match[] = {
> 

Better use devm_ioremap_resource() here, which registers the resource so they
are checked for conflicts and listed in /proc/iomem.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/25] scsi: hisi_sas: add scsi host registration

2015-10-12 Thread Arnd Bergmann
On Monday 12 October 2015 23:20:16 John Garry wrote:
> +
> +   shost = scsi_host_alloc(&hisi_sas_sht, sizeof(void *));
> +   if (!shost)
> +   return -ENOMEM;
> +
> +   hisi_hba = hisi_sas_hba_alloc(pdev, shost, np);
> +   if (!hisi_hba) {
> +   rc = -ENOMEM;
> +   goto err_out_ha;
> +   }

You can collapse the allocations into one and just pass sizeof(*hisi_hba)
instead of sizeof(void *) above.


> +   sha = SHOST_TO_SAS_HA(shost) = &hisi_hba->sha;
> +   platform_set_drvdata(pdev, sha);
> +
> +   phy_nr = port_nr = HISI_SAS_MAX_PHYS;
> +
> +   arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL);
> +   arr_port = devm_kcalloc(dev, port_nr, sizeof(void *), GFP_KERNEL);
> +   if (!arr_phy || !arr_port)
> +   return -ENOMEM;

And since these are fixed-size arrays, they can be moved in there as well.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: advansys needs ISA dma api for ISA support

2015-10-12 Thread Arnd Bergmann
The advansys drvier uses the request_dma function that is used on ISA
machines for the internal DMA controller, which causes build errors
on platforms that have ISA slots but do not provide the ISA DMA API:

drivers/scsi/advansys.c: In function 'advansys_board_found':
drivers/scsi/advansys.c:11300:10: error: implicit declaration of function 
'request_dma' [-Werror=implicit-function-declaration]

The problem now showed up in ARM randconfig builds after commit
6571fb3f8b7f ("advansys: Update to version 3.5 and remove compilation
warning") made it possible to build on platforms that have neither
VIRT_TO_BUS nor ISA_DMA_API but that do have ISA.

This adds the missing dependency.

Signed-off-by: Arnd Bergmann 

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index d2f480b04a52..d4aa6a1a806c 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -499,6 +499,7 @@ config SCSI_ADVANSYS
tristate "AdvanSys SCSI support"
depends on SCSI
depends on ISA || EISA || PCI
+   depends on ISA_DMA_API || !ISA
help
  This is a driver for all SCSI host adapters manufactured by
  AdvanSys. It is documented in the kernel source in

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/25] scsi: hisi_sas: add dev_found and port_formed

2015-10-12 Thread John Garry
Add functions to deal with lldd_dev_found and lldd_port_formed.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |  12 
 drivers/scsi/hisi_sas/hisi_sas_init.c  |   2 +
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 125 +
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c |  41 +++
 4 files changed, 180 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 976964f..3516d6f 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -47,6 +47,12 @@ enum dev_status {
HISI_SAS_DEV_EH,
 };
 
+enum hisi_sas_dev_type {
+   HISI_SAS_DEV_TYPE_STP = 0,
+   HISI_SAS_DEV_TYPE_SSP,
+   HISI_SAS_DEV_TYPE_SATA,
+};
+
 struct hisi_sas_phy {
struct hisi_hba *hisi_hba;
struct hisi_sas_port*port;
@@ -345,12 +351,16 @@ union hisi_sas_command_table {
 
 void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba);
 void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
+int hisi_sas_dev_found(struct domain_device *dev);
 int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags);
+void hisi_sas_port_formed(struct asd_sas_phy *sas_phy);
 void hisi_sas_wq_process(struct work_struct *work);
 void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
struct hisi_sas_slot *slot);
 
 /* hw specific functions */
+extern void hisi_sas_setup_itct_v1_hw(struct hisi_hba *hisi_hba,
+ struct hisi_sas_device *device);
 extern void start_delivery_v1_hw(struct hisi_hba *hisi_hba);
 extern int get_free_slot_v1_hw(struct hisi_hba *hisi_hba, int *q, int *s);
 extern int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
@@ -361,4 +371,6 @@ extern int interrupt_openall_v1_hw(struct hisi_hba 
*hisi_hba);
 extern int hw_init_v1_hw(struct hisi_hba *hisi_hba);
 extern int phys_init_v1_hw(struct hisi_hba *hisi_hba);
 extern void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no);
+extern void setup_itct_v1_hw(struct hisi_hba *hisi_hba,
+struct hisi_sas_device *device);
 #endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index c681b21..703527b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -33,7 +33,9 @@ static struct scsi_host_template hisi_sas_sht = {
 };
 
 static struct sas_domain_function_template hisi_sas_transport_ops = {
+   .lldd_dev_found = hisi_sas_dev_found,
.lldd_execute_task  = hisi_sas_queue_command,
+   .lldd_port_formed   = hisi_sas_port_formed,
 };
 
 static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 74084c2..44cb9085 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -11,6 +11,9 @@
 
 #include "hisi_sas.h"
 
+#define DEV_IS_EXPANDER(type) \
+   ((type == SAS_EDGE_EXPANDER_DEVICE) || \
+   (type == SAS_FANOUT_EXPANDER_DEVICE))
 
 #define DEV_IS_GONE(dev) \
((!dev) || (dev->dev_type == SAS_PHY_UNUSED))
@@ -352,6 +355,79 @@ void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int 
phy_no)
sas_ha->notify_port_event(sas_phy, PORTE_BYTES_DMAED);
 }
 
+struct hisi_sas_device *hisi_sas_alloc_dev(struct hisi_hba *hisi_hba)
+{
+   int dev_id;
+   struct device *dev = &hisi_hba->pdev->dev;
+
+   for (dev_id = 0; dev_id < HISI_SAS_MAX_DEVICES; dev_id++) {
+   if (hisi_hba->devices[dev_id].dev_type == SAS_PHY_UNUSED) {
+   hisi_hba->devices[dev_id].device_id = dev_id;
+   return &hisi_hba->devices[dev_id];
+   }
+   }
+
+   dev_err(dev, "alloc dev: max support %d devices - could not alloc\n",
+   HISI_SAS_MAX_DEVICES);
+
+   return NULL;
+}
+
+int hisi_sas_dev_found_notify(struct domain_device *device, int lock)
+{
+   unsigned long flags = 0;
+   int res = 0;
+   struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
+   struct domain_device *parent_dev = device->parent;
+   struct hisi_sas_device *sas_dev;
+   struct device *dev = &hisi_hba->pdev->dev;
+
+   if (lock)
+   spin_lock_irqsave(&hisi_hba->lock, flags);
+
+   sas_dev = hisi_sas_alloc_dev(hisi_hba);
+   if (!sas_dev) {
+   res = -EINVAL;
+   goto found_out;
+   }
+
+   device->lldd_dev = sas_dev;
+   sas_dev->dev_status = HISI_SAS_DEV_NORMAL;
+   sas_dev->dev_type = device->dev_type;
+   sas_dev->hisi_hba = hisi_hba;
+   sas_dev->sas_device = device;
+   setup_itct_v1_hw(hisi_hba, sas_dev);
+
+   if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) {
+   int phy_no;
+   u8 phy_num = parent_dev->ex_dev.num_phys;
+   struct ex_phy *phy;
+
+   f

[PATCH 11/25] scsi: hisi_sas: add v1 hardware register definitions

2015-10-12 Thread John Garry
Add definitions for v1 controller HW.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/Makefile |   2 +-
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 402 +
 2 files changed, 403 insertions(+), 1 deletion(-)
 create mode 100644 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c

diff --git a/drivers/scsi/hisi_sas/Makefile b/drivers/scsi/hisi_sas/Makefile
index 33f30e8..7cc6514 100644
--- a/drivers/scsi/hisi_sas/Makefile
+++ b/drivers/scsi/hisi_sas/Makefile
@@ -1,2 +1,2 @@
 obj-$(CONFIG_SCSI_HISI_SAS) += hisi_sas.o
-hisi_sas-y+= hisi_sas_init.o hisi_sas_main.o
+hisi_sas-y+= hisi_sas_init.o hisi_sas_main.o hisi_sas_v1_hw.o
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
new file mode 100644
index 000..ccc7aa7
--- /dev/null
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -0,0 +1,402 @@
+/*
+ * Copyright (c) 2015 Linaro Ltd.
+ * Copyright (c) 2015 Hisilicon Limited.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include "hisi_sas.h"
+
+/* global registers need init*/
+#define DLVRY_QUEUE_ENABLE 0x0
+#define IOST_BASE_ADDR_LO  0x8
+#define IOST_BASE_ADDR_HI  0xc
+#define ITCT_BASE_ADDR_LO  0x10
+#define ITCT_BASE_ADDR_HI  0x14
+#define BROKEN_MSG_ADDR_LO 0x18
+#define BROKEN_MSG_ADDR_HI 0x1c
+#define PHY_CONTEXT0x20
+#define PHY_STATE  0x24
+#define PHY_PORT_NUM_MA0x28
+#define PORT_STATE 0x2c
+#define PHY_CONN_RATE  0x30
+#define HGC_TRANS_TASK_CNT_LIMIT   0x38
+#define AXI_AHB_CLK_CFG0x3c
+#define HGC_SAS_TXFAIL_RETRY_CTRL  0x84
+#define HGC_GET_ITV_TIME   0x90
+#define DEVICE_MSG_WORK_MODE   0x94
+#define I_T_NEXUS_LOSS_TIME0xa0
+#define BUS_INACTIVE_LIMIT_TIME0xa8
+#define REJECT_TO_OPEN_LIMIT_TIME  0xac
+#define CFG_AGING_TIME 0xbc
+#define CFG_AGING_TIME_ITCT_REL_OFF0
+#define CFG_AGING_TIME_ITCT_REL_MSK(0x1 << CFG_AGING_TIME_ITCT_REL_OFF)
+#define HGC_DFX_CFG2   0xc0
+#define FIS_LIST_BADDR_L   0xc4
+#define CFG_1US_TIMER_TRSH 0xcc
+#define CFG_SAS_CONFIG 0xd4
+#define HGC_IOST_ECC_ADDR  0x140
+#define HGC_IOST_ECC_ADDR_BAD_OFF  16
+#define HGC_IOST_ECC_ADDR_BAD_MSK  (0x3ff << HGC_IOST_ECC_ADDR_BAD_OFF)
+#define HGC_DQ_ECC_ADDR0x144
+#define HGC_DQ_ECC_ADDR_BAD_OFF16
+#define HGC_DQ_ECC_ADDR_BAD_MSK(0xfff << 
HGC_DQ_ECC_ADDR_BAD_OFF)
+#define HGC_INVLD_DQE_INFO 0x148
+#define HGC_INVLD_DQE_INFO_DQ_OFF  0
+#define HGC_INVLD_DQE_INFO_DQ_MSK  (0x << HGC_INVLD_DQE_INFO_DQ_OFF)
+#define HGC_INVLD_DQE_INFO_TYPE_OFF16
+#define HGC_INVLD_DQE_INFO_TYPE_MSK(0x1 << HGC_INVLD_DQE_INFO_TYPE_OFF)
+#define HGC_INVLD_DQE_INFO_FORCE_OFF   17
+#define HGC_INVLD_DQE_INFO_FORCE_MSK   (0x1 << HGC_INVLD_DQE_INFO_FORCE_OFF)
+#define HGC_INVLD_DQE_INFO_PHY_OFF 18
+#define HGC_INVLD_DQE_INFO_PHY_MSK (0x1 << HGC_INVLD_DQE_INFO_PHY_OFF)
+#define HGC_INVLD_DQE_INFO_ABORT_OFF   19
+#define HGC_INVLD_DQE_INFO_ABORT_MSK   (0x1 << HGC_INVLD_DQE_INFO_ABORT_OFF)
+#define HGC_INVLD_DQE_INFO_IPTT_OF_OFF 20
+#define HGC_INVLD_DQE_INFO_IPTT_OF_MSK (0x1 << HGC_INVLD_DQE_INFO_IPTT_OF_OFF)
+#define HGC_INVLD_DQE_INFO_SSP_ERR_OFF 21
+#define HGC_INVLD_DQE_INFO_SSP_ERR_MSK (0x1 << HGC_INVLD_DQE_INFO_SSP_ERR_OFF)
+#define HGC_INVLD_DQE_INFO_OFL_OFF 22
+#define HGC_INVLD_DQE_INFO_OFL_MSK (0x1 << HGC_INVLD_DQE_INFO_OFL_OFF)
+#define HGC_ITCT_ECC_ADDR  0x150
+#define HGC_ITCT_ECC_ADDR_BAD_OFF  16
+#define HGC_ITCT_ECC_ADDR_BAD_MSK  (0x3ff << HGC_ITCT_ECC_ADDR_BAD_OFF)
+#define HGC_AXI_FIFO_ERR_INFO  0x154
+#define INT_COAL_EN0x1bc
+#define OQ_INT_COAL_TIME   0x1c0
+#define OQ_INT_COAL_CNT0x1c4
+#define ENT_INT_COAL_TIME  0x1c8
+#define ENT_INT_COAL_CNT   0x1cc
+#define OQ_INT_SRC 0x1d0
+#define OQ_INT_SRC_MSK 0x1d4
+#define ENT_INT_SRC1   0x1d8
+#define ENT_INT_SRC2   0x1dc
+#define ENT_INT_SRC2_DQ_CFG_ERR_OFF25
+#define ENT_INT_SRC2_DQ_CFG_ERR_MSK(0x1 << ENT_INT_SRC2_DQ_CFG_ERR_OFF)
+#define ENT_INT_SRC2_CQ_CFG_ERR_OFF27
+#define ENT_INT_SRC2_CQ_CFG_ERR_MSK(0x1 << ENT_INT_SRC2_CQ_CFG_ERR_OFF)
+#define ENT_INT_SRC2_AXI_WRONG_INT_OFF 28
+#define ENT_INT_SRC2_AXI_WRONG_INT_MSK (0x1 << ENT_INT_SRC2_AXI_WRONG_INT_OFF)
+#define ENT_INT_SRC2_AXI_OVERLF_INT_OFF29
+#define ENT_INT_SRC2_AXI_OVERLF_IN

[PATCH 06/25] scsi: hisi_sas: add slot init code

2015-10-12 Thread John Garry
Add functionality to init slot indexing.

Slot indexing is for the host to track which slots
(or tags) are free and which are used.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/Makefile|  2 +-
 drivers/scsi/hisi_sas/hisi_sas.h  |  2 ++
 drivers/scsi/hisi_sas/hisi_sas_init.c |  2 ++
 drivers/scsi/hisi_sas/hisi_sas_main.c | 28 
 4 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 drivers/scsi/hisi_sas/hisi_sas_main.c

diff --git a/drivers/scsi/hisi_sas/Makefile b/drivers/scsi/hisi_sas/Makefile
index 63c3c4d..33f30e8 100644
--- a/drivers/scsi/hisi_sas/Makefile
+++ b/drivers/scsi/hisi_sas/Makefile
@@ -1,2 +1,2 @@
 obj-$(CONFIG_SCSI_HISI_SAS) += hisi_sas.o
-hisi_sas-y+= hisi_sas_init.o
+hisi_sas-y+= hisi_sas_init.o hisi_sas_main.o
diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 2c15036..929c513 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -257,4 +257,6 @@ union hisi_sas_command_table {
struct hisi_sas_command_table_smp smp;
struct hisi_sas_command_table_stp stp;
 };
+
+void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba);
 #endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index 0116782..38b9ed2 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -131,6 +131,8 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct 
Scsi_Host *shost)
goto err_out;
memset(hisi_hba->sata_breakpoint, 0, s);
 
+   hisi_sas_slot_index_init(hisi_hba);
+
return 0;
 err_out:
return -ENOMEM;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
new file mode 100644
index 000..721412e
--- /dev/null
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015 Linaro Ltd.
+ * Copyright (c) 2015 Hisilicon Limited.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include "hisi_sas.h"
+
+
+static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx)
+{
+   void *bitmap = hisi_hba->slot_index_tags;
+
+   clear_bit(slot_idx, bitmap);
+}
+
+void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
+{
+   int i;
+
+   for (i = 0; i < hisi_hba->slot_index_count; ++i)
+   hisi_sas_slot_index_clear(hisi_hba, i);
+}
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/25] scsi: hisi_sas: add cq interrupt handler

2015-10-12 Thread John Garry
Add cq interrupt handler and also slot error handler
function.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |   4 +
 drivers/scsi/hisi_sas/hisi_sas_main.c  |  46 +
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 327 +
 3 files changed, 377 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 908baf3..976964f 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -347,6 +347,10 @@ void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba);
 void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
 int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags);
 void hisi_sas_wq_process(struct work_struct *work);
+void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
+   struct hisi_sas_slot *slot);
+
+/* hw specific functions */
 extern void start_delivery_v1_hw(struct hisi_hba *hisi_hba);
 extern int get_free_slot_v1_hw(struct hisi_hba *hisi_hba, int *q, int *s);
 extern int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 3a82262..74084c2 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -60,6 +60,52 @@ void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
hisi_sas_slot_index_clear(hisi_hba, i);
 }
 
+void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
+   struct sas_task *task,
+   struct hisi_sas_slot *slot)
+{
+   struct device *dev = &hisi_hba->pdev->dev;
+
+   if (!slot->task)
+   return;
+
+   if (!sas_protocol_ata(task->task_proto))
+   if (slot->n_elem)
+   dma_unmap_sg(dev, task->scatter, slot->n_elem,
+task->data_dir);
+
+   switch (task->task_proto) {
+   case SAS_PROTOCOL_SMP:
+   break;
+
+   case SAS_PROTOCOL_SATA:
+   case SAS_PROTOCOL_STP:
+   case SAS_PROTOCOL_SSP:
+   default:
+   /* do nothing */
+   break;
+   }
+
+   if (slot->command_table)
+   dma_pool_free(hisi_hba->command_table_pool,
+ slot->command_table, slot->command_table_dma);
+
+   if (slot->status_buffer)
+   dma_pool_free(hisi_hba->status_buffer_pool,
+ slot->status_buffer, slot->status_buffer_dma);
+
+   if (slot->sge_page)
+   dma_pool_free(hisi_hba->sge_page_pool, slot->sge_page,
+   slot->sge_page_dma);
+
+   list_del_init(&slot->entry);
+   task->lldd_task = NULL;
+   slot->task = NULL;
+   slot->port = NULL;
+   hisi_sas_slot_index_free(hisi_hba, slot->idx);
+   memset(slot, 0, sizeof(*slot));
+}
+
 
 static int hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba,
  struct hisi_sas_tei *tei, int is_tmf,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 6e54054..4cb0e1b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -957,6 +957,257 @@ int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
return 0;
 }
 
+/* by default, task resp is complete */
+static void slot_err_v1_hw(struct hisi_hba *hisi_hba,
+  struct sas_task *task,
+  struct hisi_sas_slot *slot)
+{
+   struct task_status_struct *tstat = &task->task_status;
+   struct hisi_sas_err_record *err_record = slot->status_buffer;
+   struct device *dev = &hisi_hba->pdev->dev;
+
+   switch (task->task_proto) {
+   case SAS_PROTOCOL_SSP:
+   {
+   int error = -1;
+   u32 dma_err_type = cpu_to_le32(err_record->dma_err_type);
+   u32 dma_tx_err_type = ((dma_err_type &
+   ERR_HDR_DMA_TX_ERR_TYPE_MSK)) >>
+   ERR_HDR_DMA_TX_ERR_TYPE_OFF;
+   u32 dma_rx_err_type = ((dma_err_type &
+   ERR_HDR_DMA_RX_ERR_TYPE_MSK)) >>
+   ERR_HDR_DMA_RX_ERR_TYPE_OFF;
+   u32 trans_tx_fail_type =
+   cpu_to_le32(err_record->trans_tx_fail_type);
+   u32 trans_rx_fail_type =
+   cpu_to_le32(err_record->trans_rx_fail_type);
+
+   if (dma_tx_err_type) {
+   /* dma tx err */
+   error = ffs(dma_tx_err_type)
+   - 1 + DMA_TX_ERR_BASE;
+   } else if (dma_rx_err_type) {
+   /* dma rx err */
+   error = ffs(dma_rx_err_type)
+   - 1 + DMA_RX_ERR_BASE;
+   } else if (trans_tx_fail_type) {

[PATCH 03/25] scsi: hisi_sas: add initial bare driver

2015-10-12 Thread John Garry
This patch adds the initial bare driver for the HiSilicon
SAS HBA. The driver includes no HW interaction, but only
the changes to build and load the driver module.

The HBA is a platform device.

Signed-off-by: John Garry 
---
 drivers/scsi/Kconfig  |  1 +
 drivers/scsi/Makefile |  1 +
 drivers/scsi/hisi_sas/Kconfig |  5 +++
 drivers/scsi/hisi_sas/Makefile|  2 ++
 drivers/scsi/hisi_sas/hisi_sas.h  | 24 +++
 drivers/scsi/hisi_sas/hisi_sas_init.c | 58 +++
 6 files changed, 91 insertions(+)
 create mode 100644 drivers/scsi/hisi_sas/Kconfig
 create mode 100644 drivers/scsi/hisi_sas/Makefile
 create mode 100644 drivers/scsi/hisi_sas/hisi_sas.h
 create mode 100644 drivers/scsi/hisi_sas/hisi_sas_init.c

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 95f7a76..5c345f9 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1774,5 +1774,6 @@ source "drivers/scsi/pcmcia/Kconfig"
 source "drivers/scsi/device_handler/Kconfig"
 
 source "drivers/scsi/osd/Kconfig"
+source "drivers/scsi/hisi_sas/Kconfig"
 
 endmenu
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 1a8c9b5..03c30de 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -158,6 +158,7 @@ obj-$(CONFIG_CHR_DEV_SCH)   += ch.o
 obj-$(CONFIG_SCSI_ENCLOSURE)   += ses.o
 
 obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/
+obj-$(CONFIG_SCSI_HISI_SAS) += hisi_sas/
 
 # This goes last, so that "real" scsi devices probe earlier
 obj-$(CONFIG_SCSI_DEBUG)   += scsi_debug.o
diff --git a/drivers/scsi/hisi_sas/Kconfig b/drivers/scsi/hisi_sas/Kconfig
new file mode 100644
index 000..a7f47a2
--- /dev/null
+++ b/drivers/scsi/hisi_sas/Kconfig
@@ -0,0 +1,5 @@
+config SCSI_HISI_SAS
+   tristate "HiSilicon SAS"
+   select SCSI_SAS_LIBSAS
+   help
+   This driver supports HiSilicon's SAS HBA
diff --git a/drivers/scsi/hisi_sas/Makefile b/drivers/scsi/hisi_sas/Makefile
new file mode 100644
index 000..63c3c4d
--- /dev/null
+++ b/drivers/scsi/hisi_sas/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_SCSI_HISI_SAS) += hisi_sas.o
+hisi_sas-y+= hisi_sas_init.o
diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
new file mode 100644
index 000..50204a2
--- /dev/null
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015 Linaro Ltd.
+ * Copyright (c) 2015 Hisilicon Limited.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#ifndef _HISI_SAS_H_
+#define _HISI_SAS_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRV_NAME "hisi_sas"
+#define DRV_VERSION "v1.0"
+
+#endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
new file mode 100644
index 000..dd83430
--- /dev/null
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015 Linaro Ltd.
+ * Copyright (c) 2015 Hisilicon Limited.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include "hisi_sas.h"
+
+static const struct of_device_id sas_of_match[] = {
+   { .compatible = "hisilicon,sas-controller-v1",},
+   {},
+};
+MODULE_DEVICE_TABLE(of, sas_of_match);
+static int hisi_sas_probe(struct platform_device *pdev)
+{
+
+   return 0;
+}
+
+static int hisi_sas_remove(struct platform_device *pdev)
+{
+   return 0;
+}
+
+static struct platform_driver hisi_sas_driver = {
+   .probe = hisi_sas_probe,
+   .remove = hisi_sas_remove,
+   .driver = {
+   .name = DRV_NAME,
+   .of_match_table = sas_of_match,
+   },
+};
+
+static __init int hisi_sas_init(void)
+{
+   pr_info("hisi_sas: driver version %s\n", DRV_VERSION);
+
+   return platform_driver_register(&hisi_sas_driver);
+}
+
+static __exit void hisi_sas_exit(void)
+{
+   platform_driver_unregister(&hisi_sas_driver);
+}
+
+module_init(hisi_sas_init);
+module_exit(hisi_sas_exit);
+
+MODULE_VERSION(DRV_VERSION);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("John Garry ");
+MODULE_DESCRIPTION("HISILICON SAS controller driver");
+MODULE_ALIAS("platform:" DRV_NAME);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/25] MAINTAINERS: add maintainer for HiSi SAS driver

2015-10-12 Thread John Garry
Add maintainer for HiSilicon SAS driver.

Signed-off-by: John Garry 
---
 MAINTAINERS | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 797236b..edea297 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4935,6 +4935,13 @@ F:   include/uapi/linux/if_hippi.h
 F: net/802/hippi.c
 F: drivers/net/hippi/
 
+HISILICON SAS Controller
+M: John Garry 
+W: http://www.hisilicon.com
+S: Supported
+F: drivers/scsi/hisi_sas/
+F: Documentation/devicetree/bindings/scsi/hisilicon-sas.txt
+
 HOST AP DRIVER
 M: Jouni Malinen 
 L: hos...@shmoo.com (subscribers-only)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/25] scsi: hisi_sas: add dev_gone and port_deformed

2015-10-12 Thread John Garry
Add function calls for lldd_dev_gone and lldd_port_deformed.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |  7 +++
 drivers/scsi/hisi_sas/hisi_sas_init.c  |  2 +
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 80 ++
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 28 
 4 files changed, 117 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 3f61a4a..265d9bd 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -352,14 +352,19 @@ union hisi_sas_command_table {
 void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba);
 void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
 int hisi_sas_dev_found(struct domain_device *dev);
+void hisi_sas_dev_gone(struct domain_device *dev);
 int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags);
 void hisi_sas_port_formed(struct asd_sas_phy *sas_phy);
+void hisi_sas_port_deformed(struct asd_sas_phy *sas_phy);
 void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy);
 void hisi_sas_wq_process(struct work_struct *work);
 void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
struct hisi_sas_slot *slot);
 
 /* hw specific functions */
+extern int slot_complete_v1_hw(struct hisi_hba *hisi_hba,
+  struct hisi_sas_slot *slot,
+  int abort);
 extern void hisi_sas_setup_itct_v1_hw(struct hisi_hba *hisi_hba,
  struct hisi_sas_device *device);
 extern void start_delivery_v1_hw(struct hisi_hba *hisi_hba);
@@ -370,6 +375,8 @@ extern int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
 extern int interrupt_init_v1_hw(struct hisi_hba *hisi_hba);
 extern int interrupt_openall_v1_hw(struct hisi_hba *hisi_hba);
 extern int hw_init_v1_hw(struct hisi_hba *hisi_hba);
+extern int free_device_v1_hw(struct hisi_hba *hisi_hba,
+struct hisi_sas_device *dev);
 extern int phys_init_v1_hw(struct hisi_hba *hisi_hba);
 extern void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no);
 extern void setup_itct_v1_hw(struct hisi_hba *hisi_hba,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index 703527b..ba64562 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -34,8 +34,10 @@ static struct scsi_host_template hisi_sas_sht = {
 
 static struct sas_domain_function_template hisi_sas_transport_ops = {
.lldd_dev_found = hisi_sas_dev_found,
+   .lldd_dev_gone  = hisi_sas_dev_gone,
.lldd_execute_task  = hisi_sas_queue_command,
.lldd_port_formed   = hisi_sas_port_formed,
+   .lldd_port_deformed = hisi_sas_port_deformed,
 };
 
 static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index fbc2cca..36ef8cd 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -514,12 +514,86 @@ void hisi_sas_port_notify_formed(struct asd_sas_phy 
*sas_phy, int lock)
spin_unlock_irqrestore(&hisi_hba->lock, flags);
 }
 
+void hisi_sas_do_release_task(struct hisi_hba *hisi_hba,
+   int phy_no, struct domain_device *device)
+{
+   struct hisi_sas_phy *phy;
+   struct hisi_sas_port *port;
+   struct hisi_sas_slot *slot, *slot2;
+   struct device *dev = &hisi_hba->pdev->dev;
+
+   phy = &hisi_hba->phy[phy_no];
+   port = phy->port;
+   if (!port)
+   return;
+
+   list_for_each_entry_safe(slot, slot2, &port->list, entry) {
+   struct sas_task *task;
+
+   task = slot->task;
+   if (device && task->dev != device)
+   continue;
+
+   dev_info(dev, "Release slot [%d:%d], task [%p]:\n",
+slot->dlvry_queue, slot->dlvry_queue_slot, task);
+   slot_complete_v1_hw(hisi_hba, slot, 1);
+   }
+}
+
+static void hisi_sas_port_notify_deformed(struct asd_sas_phy *sas_phy,
+ int lock)
+{
+   struct domain_device *device;
+   struct hisi_sas_phy *phy = sas_phy->lldd_phy;
+   struct hisi_hba *hisi_hba = phy->hisi_hba;
+   struct asd_sas_port *sas_port = sas_phy->port;
+   struct hisi_sas_port *port = sas_port->lldd_port;
+   int phy_no = 0;
+
+   port->port_attached = 0;
+   port->id = -1;
+
+   while (phy != &hisi_hba->phy[phy_no]) {
+   phy_no++;
+
+   if (phy_no >= hisi_hba->n_phy)
+   return;
+   }
+   list_for_each_entry(device, &sas_port->dev_list, dev_list_node)
+   hisi_sas_do_release_task(phy->hisi_hba, phy_no, device);
+}
 
 int hisi_sas_dev_found(struct domain_device *device)
 {
return hi

[PATCH 22/25] scsi: hisi_sas: add tmf methods

2015-10-12 Thread John Garry
Add function methods for tmf's.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h  |   7 +
 drivers/scsi/hisi_sas/hisi_sas_init.c |   6 +
 drivers/scsi/hisi_sas/hisi_sas_main.c | 385 ++
 3 files changed, 398 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 9565a2a..b488fe3 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -360,6 +360,13 @@ void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
 int hisi_sas_dev_found(struct domain_device *dev);
 void hisi_sas_dev_gone(struct domain_device *dev);
 int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags);
+int hisi_sas_abort_task(struct sas_task *task);
+int hisi_sas_abort_task_set(struct domain_device *dev, u8 *lun);
+int hisi_sas_clear_aca(struct domain_device *dev, u8 *lun);
+int hisi_sas_clear_task_set(struct domain_device *dev, u8 *lun);
+int hisi_sas_I_T_nexus_reset(struct domain_device *dev);
+int hisi_sas_lu_reset(struct domain_device *dev, u8 *lun);
+int hisi_sas_query_task(struct sas_task *task);
 void hisi_sas_port_formed(struct asd_sas_phy *sas_phy);
 void hisi_sas_port_deformed(struct asd_sas_phy *sas_phy);
 void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy);
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index caab645..b6272d8 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -38,6 +38,12 @@ static struct sas_domain_function_template 
hisi_sas_transport_ops = {
.lldd_dev_found = hisi_sas_dev_found,
.lldd_dev_gone  = hisi_sas_dev_gone,
.lldd_execute_task  = hisi_sas_queue_command,
+   .lldd_abort_task= hisi_sas_abort_task,
+   .lldd_abort_task_set= hisi_sas_abort_task_set,
+   .lldd_clear_aca = hisi_sas_clear_aca,
+   .lldd_I_T_nexus_reset   = hisi_sas_I_T_nexus_reset,
+   .lldd_lu_reset  = hisi_sas_lu_reset,
+   .lldd_query_task= hisi_sas_query_task,
.lldd_port_formed   = hisi_sas_port_formed,
.lldd_port_deformed = hisi_sas_port_deformed,
 };
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 393d22a..12af29c 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -23,6 +23,19 @@ static struct hisi_hba *dev_to_hisi_hba(struct domain_device 
*device)
return device->port->ha->lldd_ha;
 }
 
+static int hisi_sas_find_tag(struct hisi_hba *hisi_hba,
+struct sas_task *task, u32 *tag)
+{
+   if (task->lldd_task) {
+   struct hisi_sas_slot *slot;
+
+   slot = task->lldd_task;
+   *tag = slot->idx;
+   return 1;
+   }
+   return 0;
+}
+
 static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx)
 {
void *bitmap = hisi_hba->slot_index_tags;
@@ -599,6 +612,44 @@ int hisi_sas_dev_found(struct domain_device *device)
return hisi_sas_dev_found_notify(device, 1);
 }
 
+int hisi_sas_find_dev_phyno(struct domain_device *device, int *phyno)
+{
+   int i = 0, j = 0, num = 0, n = 0;
+   struct sas_ha_struct *sha = device->port->ha;
+
+   while (sha->sas_port[i]) {
+   if (sha->sas_port[i] == device->port) {
+   struct asd_sas_phy *phy;
+
+   list_for_each_entry(phy,
+   &sha->sas_port[i]->phy_list, port_phy_el) {
+   j = 0;
+
+   while (sha->sas_phy[j]) {
+   if (sha->sas_phy[j] == phy)
+   break;
+   j++;
+   }
+   phyno[n] = j;
+   num++;
+   n++;
+   }
+   break;
+   }
+   i++;
+   }
+   return num;
+}
+
+static void hisi_sas_release_task(struct hisi_hba *hisi_hba,
+   struct domain_device *device)
+{
+   int i, phyno[4], num;
+
+   num = hisi_sas_find_dev_phyno(device, phyno);
+   for (i = 0; i < num; i++)
+   hisi_sas_do_release_task(hisi_hba, phyno[i], device);
+}
 
 static void hisi_sas_dev_gone_notify(struct domain_device *device)
 {
@@ -630,6 +681,340 @@ int hisi_sas_queue_command(struct sas_task *task, gfp_t 
gfp_flags)
return hisi_sas_task_exec(task, gfp_flags, NULL, 0, NULL);
 }
 
+
+static void hisi_sas_task_done(struct sas_task *task)
+{
+   if (!del_timer(&task->slow_task->timer))
+   return;
+   complete(&task->slow_task->completion);
+}
+
+static void hisi_sas_tmf_timedout(unsigned long data)
+{
+   struct sas_task *task = (struc

[PATCH 07/25] scsi: hisi_sas: add ioremap for device HW

2015-10-12 Thread John Garry
This includes registers for core SAS controllers
and also SAS control registers.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h  |  2 ++
 drivers/scsi/hisi_sas/hisi_sas_init.c | 25 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 929c513..5f72d98 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -69,6 +69,8 @@ struct hisi_hba {
 
struct platform_device *pdev;
 
+   void __iomem *regs;
+   void __iomem *ctrl_regs;
 
u8 sas_addr[SAS_ADDR_SIZE];
 
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index 38b9ed2..8f1e856 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -195,6 +195,28 @@ static void hisi_sas_free(struct hisi_hba *hisi_hba)
  hisi_hba->sata_breakpoint_dma);
 }
 
+int hisi_sas_ioremap(struct hisi_hba *hisi_hba)
+{
+   struct platform_device *pdev = hisi_hba->pdev;
+   struct device *dev = &pdev->dev;
+   struct resource *res;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   hisi_hba->regs = devm_ioremap(dev,
+ res->start,
+ resource_size(res));
+   if (!hisi_hba->regs)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+   hisi_hba->ctrl_regs = devm_ioremap(dev,
+  res->start,
+  resource_size(res));
+   if (!hisi_hba->ctrl_regs)
+   return -ENOMEM;
+
+   return 0;
+}
 
 static const struct of_device_id sas_of_match[] = {
{ .compatible = "hisilicon,sas-controller-v1",},
@@ -241,6 +263,9 @@ static struct hisi_hba *hisi_sas_hba_alloc(
 
hisi_hba->shost = shost;
 
+   if (hisi_sas_ioremap(hisi_hba))
+   goto err_out;
+
if (hisi_sas_alloc(hisi_hba, shost)) {
hisi_sas_free(hisi_hba);
goto err_out;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/25] scsi: hisi_sas: add smp protocol support

2015-10-12 Thread John Garry
Add support for smp function, which allows devices
attached by expander to be controlled.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |  4 ++
 drivers/scsi/hisi_sas/hisi_sas_main.c  |  9 +++-
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 97 +-
 3 files changed, 107 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 265d9bd..be2cdf5 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -34,6 +34,8 @@
(((sizeof(union hisi_sas_command_table)+3)/4)*4)
 
 #define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024)
+#define HISI_SAS_MAX_SMP_RESP_SZ 1028
+
 #define HISI_SAS_NAME_LEN 32
 #define HISI_SAS_RESET_REG_CNT 5
 
@@ -372,6 +374,8 @@ extern int get_free_slot_v1_hw(struct hisi_hba *hisi_hba, 
int *q, int *s);
 extern int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
  struct hisi_sas_tei *tei, int is_tmf,
  struct hisi_sas_tmf_task *tmf);
+extern int prep_smp_v1_hw(struct hisi_hba *hisi_hba,
+ struct hisi_sas_tei *tei);
 extern int interrupt_init_v1_hw(struct hisi_hba *hisi_hba);
 extern int interrupt_openall_v1_hw(struct hisi_hba *hisi_hba);
 extern int hw_init_v1_hw(struct hisi_hba *hisi_hba);
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 36ef8cd..91620b0 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -109,6 +109,11 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
memset(slot, 0, sizeof(*slot));
 }
 
+static int hisi_sas_task_prep_smp(struct hisi_hba *hisi_hba,
+   struct hisi_sas_tei *tei)
+{
+   return prep_smp_v1_hw(hisi_hba, tei);
+}
 
 static int hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba,
  struct hisi_sas_tei *tei, int is_tmf,
@@ -235,10 +240,12 @@ static int hisi_sas_task_prep(struct sas_task *task,
tei.n_elem = n_elem;
tei.slot = slot;
switch (task->task_proto) {
+   case SAS_PROTOCOL_SMP:
+   rc = hisi_sas_task_prep_smp(hisi_hba, &tei);
+   break;
case SAS_PROTOCOL_SSP:
rc = hisi_sas_task_prep_ssp(hisi_hba, &tei, is_tmf, tmf);
break;
-   case SAS_PROTOCOL_SMP:
case SAS_PROTOCOL_SATA:
case SAS_PROTOCOL_STP:
case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 2ad2ffa..b470c72 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -913,6 +913,80 @@ static int prep_prd_sge_v1_hw(struct hisi_hba *hisi_hba,
return 0;
 }
 
+int prep_smp_v1_hw(struct hisi_hba *hisi_hba,
+  struct hisi_sas_tei *tei)
+{
+   struct sas_task *task = tei->task;
+   struct hisi_sas_cmd_hdr *hdr = tei->hdr;
+   struct domain_device *device = task->dev;
+   struct device *dev = &hisi_hba->pdev->dev;
+   struct hisi_sas_port *port = tei->port;
+   struct scatterlist *sg_req, *sg_resp;
+   struct hisi_sas_device *sas_dev = device->lldd_dev;
+   dma_addr_t req_dma_addr;
+   unsigned int req_len, resp_len;
+   int elem, rc;
+   struct hisi_sas_slot *slot = tei->slot;
+
+   /*
+   * DMA-map SMP request, response buffers
+   */
+   /* req */
+   sg_req = &task->smp_task.smp_req;
+   elem = dma_map_sg(dev, sg_req, 1, DMA_TO_DEVICE);
+   if (!elem)
+   return -ENOMEM;
+   req_len = sg_dma_len(sg_req);
+   req_dma_addr = sg_dma_address(sg_req);
+
+   /* resp */
+   sg_resp = &task->smp_task.smp_resp;
+   elem = dma_map_sg(dev, sg_resp, 1, DMA_FROM_DEVICE);
+   if (!elem) {
+   rc = -ENOMEM;
+   goto err_out_req;
+   }
+   resp_len = sg_dma_len(sg_resp);
+   if ((req_len & 0x3) || (resp_len & 0x3)) {
+   rc = -EINVAL;
+   goto err_out_resp;
+   }
+
+   /* create header */
+   /* dw0 */
+   hdr->dw0 = cpu_to_le32((port->id << CMD_HDR_PORT_OFF) |
+  (1 << CMD_HDR_PRIORITY_OFF) | /* high pri */
+  (1 << CMD_HDR_MODE_OFF) | /* ini mode */
+  (2 << CMD_HDR_CMD_OFF)); /* smp */
+
+   /* map itct entry */
+   hdr->dw1 = cpu_to_le32(sas_dev->device_id << CMD_HDR_DEVICE_ID_OFF);
+
+   /* dw2 */
+   hdr->dw2 = cpu_to_le32req_len-4)/4) << CMD_HDR_CFL_OFF) |
+  (HISI_SAS_MAX_SMP_RESP_SZ/4 <<
+  CMD_HDR_MRFL_OFF));
+
+   hdr->transfer_tags = cpu_to_le32(tei->iptt << CMD_HDR_IPTT_OFF);
+
+   hdr->cmd_table_addr_lo = cpu_to_le32(lower_32_bits(req_dma_addr));
+   hdr->cmd_table_addr_hi = cpu_to_

[PATCH 01/25] [SCSI] sas: centralise ssp frame information units

2015-10-12 Thread John Garry
The xfer_rdy, command, and task frame's iu structures
are not available in , but only aic94xx
driver folder.
Add them to include/scsi/sas.h

Signed-off-by: John Garry 
---
 drivers/scsi/aic94xx/aic94xx_sas.h | 49 -
 include/scsi/sas.h | 74 ++
 2 files changed, 80 insertions(+), 43 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_sas.h 
b/drivers/scsi/aic94xx/aic94xx_sas.h
index 912e6b7..101072c 100644
--- a/drivers/scsi/aic94xx/aic94xx_sas.h
+++ b/drivers/scsi/aic94xx/aic94xx_sas.h
@@ -327,46 +327,9 @@ struct scb_header {
 
 #define LUN_SIZE8
 
-/* See SAS spec, task IU
- */
-struct ssp_task_iu {
-   u8 lun[LUN_SIZE]; /* BE */
-   u16_r_a;
-   u8 tmf;
-   u8 _r_b;
-   __be16 tag;   /* BE */
-   u8 _r_c[14];
-} __attribute__ ((packed));
-
-/* See SAS spec, command IU
- */
-struct ssp_command_iu {
-   u8 lun[LUN_SIZE];
-   u8 _r_a;
-   u8 efb_prio_attr; /* enable first burst, task prio & attr */
-#define EFB_MASK0x80
-#define TASK_PRIO_MASK 0x78
-#define TASK_ATTR_MASK  0x07
-
-   u8_r_b;
-   u8 add_cdb_len;   /* in dwords, since bit 0,1 are reserved */
-   union {
-   u8 cdb[16];
-   struct {
-   __le64 long_cdb_addr; /* bus address, LE */
-   __le32 long_cdb_size; /* LE */
-   u8 _r_c[3];
-   u8 eol_ds;/* eol:6,6, ds:5,4 */
-   } long_cdb;   /* sequencer extension */
-   };
-} __attribute__ ((packed));
-
-struct xfer_rdy_iu {
-   __be32 requested_offset;  /* BE */
-   __be32 write_data_len;/* BE */
-   __be32 _r_a;
-} __attribute__ ((packed));
-
+#define EFB_MASK0x80
+#define TASK_PRIO_MASK  0x78
+#define TASK_ATTR_MASK  0x07
 /* -- SCB tasks -- */
 
 /* This is both ssp_task and long_ssp_task
@@ -511,7 +474,7 @@ struct abort_task {
u8 proto_conn_rate;
__le32 _r_a;
struct ssp_frame_hdr ssp_frame;
-   struct ssp_task_iu ssp_task;
+   struct ssp_tmf_iu ssp_task;
__le16 sister_scb;
__le16 conn_handle;
u8 flags; /* ovrd_itnl_timer:3,3, suspend_data_trans:2,2 */
@@ -549,7 +512,7 @@ struct clear_nexus {
u8 _r_b[3];
u8 conn_mask;
u8 _r_c[19];
-   struct ssp_task_iu ssp_task; /* LUN and TAG */
+   struct ssp_tmf_iu ssp_task; /* LUN and TAG */
__le16 _r_d;
__le16 conn_handle;
__le64 _r_e;
@@ -562,7 +525,7 @@ struct initiate_ssp_tmf {
u8 proto_conn_rate;
__le32 _r_a;
struct ssp_frame_hdr ssp_frame;
-   struct ssp_task_iu ssp_task;
+   struct ssp_tmf_iu ssp_task;
__le16 sister_scb;
__le16 conn_handle;
u8 flags; /* itnl override and suspend data tx */
diff --git a/include/scsi/sas.h b/include/scsi/sas.h
index 0d2607d..42a84ef 100644
--- a/include/scsi/sas.h
+++ b/include/scsi/sas.h
@@ -344,6 +344,43 @@ struct ssp_response_iu {
u8 sense_data[0];
 } __attribute__ ((packed));
 
+struct ssp_command_iu {
+   u8 lun[8];
+   u8 _r_a;
+
+   union {
+   struct {
+   u8  attr:3;
+   u8  prio:4;
+   u8  efb:1;
+   };
+   u8 efb_prio_attr;
+   };
+
+   u8_r_b;
+
+   u8_r_c:2;
+   u8add_cdb_len:6;
+
+   u8cdb[16];
+   u8add_cdb[0];
+} __attribute__ ((packed));
+
+struct xfer_rdy_iu {
+   __be32 requested_offset;
+   __be32 write_data_len;
+   __be32 _r_a;
+} __attribute__ ((packed));
+
+struct ssp_tmf_iu {
+   u8 lun[8];
+   u16_r_a;
+   u8 tmf;
+   u8 _r_b;
+   __be16 tag;
+   u8 _r_c[14];
+} __attribute__ ((packed));
+
 /* -- SMP -- */
 
 struct report_general_resp {
@@ -538,6 +575,43 @@ struct ssp_response_iu {
u8 sense_data[0];
 } __attribute__ ((packed));
 
+struct ssp_command_iu {
+   u8 lun[8];
+   u8 _r_a;
+
+   union {
+   struct {
+   u8  efb:1;
+   u8  prio:4;
+   u8  attr:3;
+   };
+   u8 efb_prio_attr;
+   };
+
+   u8_r_b;
+
+   u8add_cdb_len:6;
+   u8_r_c:2;
+
+   u8cdb[16];
+   u8add_cdb[0];
+} __attribute__ ((packed));
+
+struct xfer_rdy_iu {
+   __be32 requested_offset;
+   __be32 write_data_len;
+   __be32 _r_a;
+} __attribute__ ((packed));
+
+struct ssp_tmf_iu {
+   u8 lun[8];
+   u16_r_a;
+   u8 tmf;
+   u8 _r_b;
+   __be16 tag;
+   u8 _r_c[14];
+} __attribute__ ((packed));
+
 /* -- SMP -- */
 
 struct

[PATCH 02/25] devicetree: bindings: scsi: HiSi SAS

2015-10-12 Thread John Garry
Add devicetree bindings for HiSilicon SAS driver.

Signed-off-by: John Garry 
---
 .../devicetree/bindings/scsi/hisilicon-sas.txt | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/scsi/hisilicon-sas.txt

diff --git a/Documentation/devicetree/bindings/scsi/hisilicon-sas.txt 
b/Documentation/devicetree/bindings/scsi/hisilicon-sas.txt
new file mode 100644
index 000..472c022
--- /dev/null
+++ b/Documentation/devicetree/bindings/scsi/hisilicon-sas.txt
@@ -0,0 +1,63 @@
+* HiSilison SAS controller
+
+The HiSilicon SAS controller supports SAS/SATA.
+
+Main node required properties:
+  - compatible : value should be as follows:
+   (a) "hisilicon,sas-controller-v1" for v1 of HiSilicon SAS controller IP
+
+  - controller-id : identifier for controller in the SoC
+
+  - reg : Address and length of the register sets for the device
+   - SAS controller registers
+   - SAS controller control registers
+
+  - reset-reg : offset to reset, status, and clock registers in control 
registers
+
+  - queue-count : number of delivery and completion queues in the controller
+
+  - phy-count : number of phys accessible by the controller
+
+  - interrupts : Interrupts for phys, completion queues, and fatal
+interrupts:
+ - Each phy has 3 interrupt sources:
+   - broadcast
+   - phyup
+   - abnormal
+ - Each completion queue has 1 interrupt source
+ - Each controller has 2 fatal interrupt sources:
+   - ECC
+   - AXI bus
+
+Example:
+   sas0: sas@c100 {
+   compatible = "hisilicon,sas-controller-v1";
+   controller-id = <0>;
+   reg = <0x0 0xc100 0x0 0x1>,
+   <0x0 0xc000 0x0 0x1>;
+   reset-reg = <0xa60 0x33c 0x5a30 0xa64 0x338>;
+   queue-count = <32>;
+   phy-count = <8>;
+   #interrupt-cells = <2>;
+   dma-coherent;
+   interrupt-parent = <&mbigen_dsa>;
+   interrupts = <259 4>, <263 4>,<264 4>,/* phy irq(0~79) */
+   <269 4>,<273 4>,<274 4>,/* phy irq(0~79) */
+   <279 4>,<283 4>,<284 4>,/* phy irq(0~79) */
+   <289 4>,<293 4>,<294 4>,/* phy irq(0~79) */
+   <299 4>,<303 4>,<304 4>,/* phy irq(0~79) */
+   <309 4>,<313 4>,<314 4>,/* phy irq(0~79) */
+   <319 4>,<323 4>,<324 4>,/* phy irq(0~79) */
+   <329 4>,<333 4>,<334 4>,/* phy irq(0~79) */
+   <336 1>,<337 1>,<338 1>,<339 1>,<340 1>,
+   <341 1>,<342 1>,<343 1>,/* cq irq (80~111) */
+   <344 1>,<345 1>,<346 1>,<347 1>,<348 1>,
+   <349 1>,<350 1>,<351 1>,/* cq irq (80~111) */
+   <352 1>,<353 1>,<354 1>,<355 1>,<356 1>,
+   <357 1>,<358 1>,<359 1>,/* cq irq (80~111) */
+   <360 1>,<361 1>,<362 1>,<363 1>,<364 1>,
+   <365 1>,<366 1>,<367 1>,/* cq irq (80~111) */
+   <376 4>,/* chip fatal error irq(120) */
+   <381 4>;/* chip fatal error irq(125) */
+   status = "okay";
+   };
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/25] scsi: hisi_sas: add scsi host registration

2015-10-12 Thread John Garry
Add functionality to register device as a scsi host.

The SAS domain transport ops are empty at this point.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h  |  32 +
 drivers/scsi/hisi_sas/hisi_sas_init.c | 125 ++
 2 files changed, 157 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 50204a2..1a90b54 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -21,4 +21,36 @@
 #define DRV_NAME "hisi_sas"
 #define DRV_VERSION "v1.0"
 
+#define HISI_SAS_MAX_PHYS  9
+#define HISI_SAS_MAX_ITCT_ENTRIES 4096
+#define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES
+#define HISI_SAS_COMMAND_ENTRIES 8192
+
+
+struct hisi_sas_phy {
+   struct hisi_sas_port*port;
+   struct asd_sas_phy  sas_phy;
+};
+
+struct hisi_sas_port {
+   struct asd_sas_port sas_port;
+};
+
+struct hisi_hba {
+   spinlock_t  lock;
+
+   struct platform_device *pdev;
+
+
+   u8 sas_addr[SAS_ADDR_SIZE];
+
+   int n_phy;
+   /* SCSI/SAS glue */
+   struct sas_ha_struct sha;
+   struct Scsi_Host *shost;
+   struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS];
+   struct hisi_sas_port port[HISI_SAS_MAX_PHYS];
+};
+
+#define HISI_SAS_SGE_PAGE_CNT SCSI_MAX_SG_SEGMENTS
 #endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index dd83430..2cae458 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -10,20 +10,140 @@
  */
 
 #include "hisi_sas.h"
+static struct scsi_transport_template *hisi_sas_stt;
+
+static struct scsi_host_template hisi_sas_sht = {
+   .module = THIS_MODULE,
+   .name   = DRV_NAME,
+   .queuecommand   = sas_queuecommand,
+   .target_alloc   = sas_target_alloc,
+   .slave_configure= sas_slave_configure,
+   .change_queue_depth = sas_change_queue_depth,
+   .bios_param = sas_bios_param,
+   .can_queue  = 1,
+   .cmd_per_lun= 1,
+   .this_id= -1,
+   .sg_tablesize   = SG_ALL,
+   .max_sectors= SCSI_DEFAULT_MAX_SECTORS,
+   .use_clustering = ENABLE_CLUSTERING,
+   .eh_device_reset_handler = sas_eh_device_reset_handler,
+   .eh_bus_reset_handler   = sas_eh_bus_reset_handler,
+   .target_destroy = sas_target_destroy,
+   .ioctl  = sas_ioctl,
+};
+
+static struct sas_domain_function_template hisi_sas_transport_ops = {
+};
+
 
 static const struct of_device_id sas_of_match[] = {
{ .compatible = "hisilicon,sas-controller-v1",},
{},
 };
 MODULE_DEVICE_TABLE(of, sas_of_match);
+
+static struct hisi_hba *hisi_sas_hba_alloc(
+   struct platform_device *pdev,
+   struct Scsi_Host *shost,
+   struct device_node *np)
+{
+   int interrupt_count, interrupt_cells;
+   struct hisi_hba *hisi_hba;
+
+   hisi_hba = devm_kzalloc(&pdev->dev, sizeof(*hisi_hba), GFP_KERNEL);
+   if (!hisi_hba)
+   goto err_out;
+
+   hisi_hba->pdev = pdev;
+   hisi_hba->shost = shost;
+
+   return hisi_hba;
+err_out:
+   dev_err(&pdev->dev, "hba alloc failed\n");
+   return NULL;
+}
+
 static int hisi_sas_probe(struct platform_device *pdev)
 {
+   struct Scsi_Host *shost;
+   struct hisi_hba *hisi_hba;
+   struct device_node *np = pdev->dev.of_node;
+   struct device *dev = &pdev->dev;
+   struct asd_sas_phy **arr_phy;
+   struct asd_sas_port **arr_port;
+   struct sas_ha_struct *sha;
+   int rc, phy_nr, port_nr, i;
+
+   shost = scsi_host_alloc(&hisi_sas_sht, sizeof(void *));
+   if (!shost)
+   return -ENOMEM;
+
+   hisi_hba = hisi_sas_hba_alloc(pdev, shost, np);
+   if (!hisi_hba) {
+   rc = -ENOMEM;
+   goto err_out_ha;
+   }
+
+   sha = SHOST_TO_SAS_HA(shost) = &hisi_hba->sha;
+   platform_set_drvdata(pdev, sha);
+
+   phy_nr = port_nr = HISI_SAS_MAX_PHYS;
+
+   arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL);
+   arr_port = devm_kcalloc(dev, port_nr, sizeof(void *), GFP_KERNEL);
+   if (!arr_phy || !arr_port)
+   return -ENOMEM;
+
+   sha->sas_phy = arr_phy;
+   sha->sas_port = arr_port;
+   sha->core.shost = shost;
+   sha->lldd_ha = hisi_hba;
+
+   shost->transportt = hisi_sas_stt;
+   shost->max_id = HISI_SAS_MAX_DEVICES;
+   shost->max_lun = ~0;
+   shost->max_channel = 1;
+   shost->max_cmd_len = 16;
+   shost->sg_tablesize = min_t(u16, SG_ALL, HISI_SAS_SGE_PAGE_CNT);
+   shost->can_queue = HISI_SAS_COMMAND_ENTRIES;
+   shost->cmd_per_lun = HISI_SAS_COMMAND_ENTRIES;
+
+   sha->sas_ha_name = DRV_NAME;
+   sha->dev = &hisi_hba->pdev->dev;

[PATCH 10/25] scsi: hisi_sas: add misc HBA initialization

2015-10-12 Thread John Garry
This includes:
- host port structure initialisation
- host device structure initialisation
- wq initialisation
- host structure timer init
- DMA mask configuration
- call to scan host

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h  | 56 +++
 drivers/scsi/hisi_sas/hisi_sas_init.c | 35 ++
 drivers/scsi/hisi_sas/hisi_sas_main.c | 31 +++
 3 files changed, 122 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 6c5d22a..1a26f27 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -35,13 +35,36 @@
 
 #define HISI_SAS_NAME_LEN 32
 
+
+enum dev_status {
+   HISI_SAS_DEV_NORMAL,
+   HISI_SAS_DEV_EH,
+};
+
 struct hisi_sas_phy {
+   struct hisi_hba *hisi_hba;
struct hisi_sas_port*port;
struct asd_sas_phy  sas_phy;
+   struct sas_identify identify;
+   struct timer_list   timer;
+   u64 port_id; /* from hw */
+   u64 dev_sas_addr;
+   u64 phy_type;
+   u64 frame_rcvd_size;
+   u8  frame_rcvd[32];
+   u8  phy_attached;
+   u8  reserved[3];
+   u64 phy_event;
+   int eye_diag_done;
+   enum sas_linkrate   minimum_linkrate;
+   enum sas_linkrate   maximum_linkrate;
 };
 
 struct hisi_sas_port {
struct asd_sas_port sas_port;
+   u8  port_attached;
+   u8  id; /* from hw */
+   struct list_headlist;
 };
 
 struct hisi_sas_cq {
@@ -49,6 +72,18 @@ struct hisi_sas_cq {
int id;
 };
 
+struct hisi_sas_device {
+   enum sas_device_typedev_type;
+   struct hisi_hba *hisi_hba;
+   struct domain_device*sas_device;
+   u64 attached_phy;
+   u64 device_id;
+   u64 running_req;
+   struct hisi_sas_itct *itct;
+   u8 dev_status;
+   u64 reserved;
+};
+
 struct hisi_sas_slot {
struct list_head entry;
struct sas_task *task;
@@ -68,6 +103,19 @@ struct hisi_sas_slot {
struct hisi_sas_sge_page *sge_page;
dma_addr_t sge_page_dma;
 };
+
+enum hisi_sas_wq_event {
+   PHYUP,
+};
+
+struct hisi_sas_wq {
+   struct work_struct  work_struct;
+   struct hisi_hba *hisi_hba;
+   int phy_no;
+   int event;
+   int data;
+};
+
 struct hisi_hba {
spinlock_t  lock;
 
@@ -88,6 +136,10 @@ struct hisi_hba {
 
int n_phy;
 
+
+   struct timer_list timer;
+   struct workqueue_struct *wq;
+
int slot_index_count;
unsigned long *slot_index_tags;
 
@@ -103,6 +155,8 @@ struct hisi_hba {
int id;
int queue_count;
char*int_names;
+
+   struct hisi_sas_device  devices[HISI_SAS_MAX_DEVICES];
struct dma_pool *command_table_pool;
struct dma_pool *status_buffer_pool;
struct hisi_sas_itct *itct;
@@ -267,4 +321,6 @@ union hisi_sas_command_table {
 };
 
 void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba);
+void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
+void hisi_sas_wq_process(struct work_struct *work);
 #endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index c295c39..558e0e7 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -41,6 +41,20 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct 
Scsi_Host *shost)
char name[32];
struct device *dev = &hisi_hba->pdev->dev;
 
+   spin_lock_init(&hisi_hba->lock);
+   for (i = 0; i < hisi_hba->n_phy; i++) {
+   hisi_sas_phy_init(hisi_hba, i);
+   hisi_hba->port[i].port_attached = 0;
+   hisi_hba->port[i].id = -1;
+   INIT_LIST_HEAD(&hisi_hba->port[i].list);
+   }
+
+   for (i = 0; i < HISI_SAS_MAX_DEVICES; i++) {
+   hisi_hba->devices[i].dev_type = SAS_PHY_UNUSED;
+   hisi_hba->devices[i].device_id = i;
+   hisi_hba->devices[i].dev_status = HISI_SAS_DEV_NORMAL;
+   }
+
for (i = 0; i < hisi_hba->queue_count; i++) {
struct hisi_sas_cq *cq = &hisi_hba->cq[i];
 
@@ -139,6 +153,13 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, 
struct Scsi_Host *shost)
 
hisi_sas_slot_index_init(hisi_hba);
 
+   sprintf(name, "%s%d", "hisi_sas", hisi_hba->id);
+   hisi_hba->wq = create_singlethread_workqueue(name);
+   if (!hisi_hba->wq) {
+   dev_err(dev, "sas_alloc: failed to create workqueue\n");
+   goto err_out;
+   }
+
return 0;
 err_out:
return -ENOMEM;
@@ -199,6 +220,9 @@ static void hisi_sas_free(struct hisi_hba *hisi_hba)
dma_free_coherent(dev, s,
  hisi_hba->sata_breakpoint,
  hisi

[PATCH 17/25] scsi: hisi_sas: add abnormal irq handler

2015-10-12 Thread John Garry
Add abnormal irq handler. This handler is concerned with
phy down event.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |  1 +
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 24 +++
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 56 ++
 3 files changed, 81 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 3516d6f..3f61a4a 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -354,6 +354,7 @@ void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
 int hisi_sas_dev_found(struct domain_device *dev);
 int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags);
 void hisi_sas_port_formed(struct asd_sas_phy *sas_phy);
+void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy);
 void hisi_sas_wq_process(struct work_struct *work);
 void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
struct hisi_sas_slot *slot);
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 44cb9085..fbc2cca 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -529,3 +529,27 @@ void hisi_sas_port_formed(struct asd_sas_phy *sas_phy)
 {
hisi_sas_port_notify_formed(sas_phy, 1);
 }
+static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy)
+{
+   phy->phy_attached = 0;
+   phy->phy_type = 0;
+}
+
+void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy)
+{
+   struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
+   struct asd_sas_phy *sas_phy = &phy->sas_phy;
+   struct sas_ha_struct *sas_ha = &hisi_hba->sha;
+
+   if (rdy) {
+   /* Phy down but ready */
+   hisi_sas_bytes_dmaed(hisi_hba, phy_no);
+   hisi_sas_port_notify_formed(sas_phy, 0);
+   } else {
+   /* Phy down and not ready */
+   sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL);
+   phy->phy_attached = 0;
+   sas_phy_disconnected(sas_phy);
+   hisi_sas_phy_disconnected(phy);
+   }
+}
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index e8b9dc3..fadd163 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -1342,7 +1342,61 @@ end:
return res;
 }
 
+static irqreturn_t int_abnormal_v1_hw(int irq, void *p)
+{
+   struct hisi_sas_phy *phy = p;
+   struct hisi_hba *hisi_hba = phy->hisi_hba;
+   u32 irq_value, irq_mask_old;
+   struct device *dev = &hisi_hba->pdev->dev;
+   struct asd_sas_phy *sas_phy = &phy->sas_phy;
+   int phy_no = sas_phy->id;
 
+   /* mask_int0 */
+   irq_mask_old = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT0_MSK);
+   hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK, 0x3f);
+
+   /* read int0 */
+   irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT0);
+
+   if (irq_value & CHL_INT0_PHYCTRL_NOTRDY_MSK) {
+   u32 phy_state = hisi_sas_read32(hisi_hba, PHY_STATE);
+
+   hisi_sas_phy_down(hisi_hba,
+   phy_no,
+   (phy_state & 1 << phy_no) ? 1 : 0);
+   }
+
+   if (irq_value & CHL_INT0_ID_TIMEOUT_MSK)
+   dev_dbg(dev, "abnormal: ID_TIMEOUT phy%d identify timeout\n",
+   phy_no);
+
+   if (irq_value & CHL_INT0_DWS_LOST_MSK)
+   dev_dbg(dev, "abnormal: DWS_LOST phy%d dws lost\n", phy_no);
+
+   if (irq_value & CHL_INT0_SN_FAIL_NGR_MSK)
+   dev_dbg(dev, "abnormal: SN_FAIL_NGR phy%d sn fail ngr\n",
+   phy_no);
+
+   if (irq_value & CHL_INT0_SL_IDAF_FAIL_MSK ||
+   irq_value & CHL_INT0_SL_OPAF_FAIL_MSK)
+   dev_dbg(dev, "abnormal: SL_ID/OPAF_FAIL phy%d check adr frm 
err\n",
+   phy_no);
+
+   if (irq_value & CHL_INT0_SL_PS_FAIL_OFF)
+   dev_dbg(dev, "abnormal: SL_PS_FAIL phy%d fail\n", phy_no);
+
+   /* write to zero */
+   hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, irq_value);
+
+   if (irq_value & CHL_INT0_PHYCTRL_NOTRDY_MSK)
+   hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK,
+   0x3f & ~CHL_INT0_MSK_PHYCTRL_NOTRDY_MSK);
+   else
+   hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK,
+   irq_mask_old);
+
+   return IRQ_HANDLED;
+}
 
 static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
 {
@@ -1397,12 +1451,14 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
 
 static const char phy_int_names[HISI_SAS_PHY_INT_NR][32] = {
{"Phy Up"},
+   {"Abnormal"},
 };
 
 static const char cq_int_name[32] = "cq";
 
 static irq_handler_t phy_interrupts[HISI_SAS_PHY_INT_NR] = {
int_phyup_v1_hw,
+   in

[PATCH 21/25] scsi: hisi_sas: add scan finished and start

2015-10-12 Thread John Garry
Add functions for scsi host template scan_finished
and scan_start methods.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h  |  4 
 drivers/scsi/hisi_sas/hisi_sas_init.c |  2 ++
 drivers/scsi/hisi_sas/hisi_sas_main.c | 24 
 3 files changed, 30 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index be2cdf5..9565a2a 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -165,6 +165,7 @@ struct hisi_hba {
 
int n_phy;
 
+   int scan_finished;
 
struct timer_list timer;
struct workqueue_struct *wq;
@@ -351,6 +352,9 @@ union hisi_sas_command_table {
struct hisi_sas_command_table_stp stp;
 };
 
+int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time);
+void hisi_sas_scan_start(struct Scsi_Host *shost);
+
 void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba);
 void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
 int hisi_sas_dev_found(struct domain_device *dev);
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index ba64562..caab645 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -18,6 +18,8 @@ static struct scsi_host_template hisi_sas_sht = {
.queuecommand   = sas_queuecommand,
.target_alloc   = sas_target_alloc,
.slave_configure= sas_slave_configure,
+   .scan_finished  = hisi_sas_scan_finished,
+   .scan_start = hisi_sas_scan_start,
.change_queue_depth = sas_change_queue_depth,
.bios_param = sas_bios_param,
.can_queue  = 1,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 91620b0..393d22a 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -435,6 +435,30 @@ found_out:
return res;
 }
 
+void hisi_sas_scan_start(struct Scsi_Host *shost)
+{
+   struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+   struct hisi_hba *hisi_hba = sha->lldd_ha;
+   int i;
+
+   for (i = 0; i < hisi_hba->n_phy; ++i)
+   hisi_sas_bytes_dmaed(hisi_hba, i);
+
+   hisi_hba->scan_finished = 1;
+}
+
+int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time)
+{
+   struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+   struct hisi_hba *hisi_hba = sha->lldd_ha;
+
+   if (hisi_hba->scan_finished == 0)
+   return 0;
+
+   sas_drain_work(sha);
+   return 1;
+}
+
 
 static void hisi_sas_phyup_work(struct hisi_hba *hisi_hba,
  int phy_no)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/25] scsi: hisi_sas: add fatal irq handler

2015-10-12 Thread John Garry
Add handlers for fatal interrupts.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 118 +
 1 file changed, 118 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index b5ba46a..bc8e23e 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -1621,6 +1621,91 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
return IRQ_HANDLED;
 }
 
+static irqreturn_t fatal_ecc_int_v1_hw(int irq, void *p)
+{
+   struct hisi_hba *hisi_hba = p;
+   u32 ecc_int = hisi_sas_read32(hisi_hba, SAS_ECC_INTR);
+
+   if (ecc_int & SAS_ECC_INTR_DQ_ECC1B_MSK) {
+   u32 ecc_err = hisi_sas_read32(hisi_hba, HGC_ECC_ERR);
+
+   panic("Fatal DQ 1b ECC interrupt on controller %d (0x%x)\n",
+   hisi_hba->id, ecc_err);
+   }
+
+   if (ecc_int & SAS_ECC_INTR_DQ_ECCBAD_MSK) {
+   u32 addr = (hisi_sas_read32(hisi_hba, HGC_DQ_ECC_ADDR) &
+   HGC_DQ_ECC_ADDR_BAD_MSK) >>
+   HGC_DQ_ECC_ADDR_BAD_OFF;
+
+   panic("Fatal DQ RAM ECC interrupt on controller %d @ 0x%08x\n",
+   hisi_hba->id, addr);
+   }
+
+   if (ecc_int & SAS_ECC_INTR_IOST_ECC1B_MSK) {
+   u32 ecc_err = hisi_sas_read32(hisi_hba, HGC_ECC_ERR);
+
+   panic("Fatal IOST 1b ECC interrupt on controller %d (0x%x)\n",
+   hisi_hba->id, ecc_err);
+   }
+
+   if (ecc_int & SAS_ECC_INTR_IOST_ECCBAD_MSK) {
+   u32 addr = (hisi_sas_read32(hisi_hba, HGC_IOST_ECC_ADDR) &
+   HGC_IOST_ECC_ADDR_BAD_MSK) >>
+   HGC_IOST_ECC_ADDR_BAD_OFF;
+
+   panic("Fatal IOST RAM ECC interrupt on controller %d @ 
0x%08x\n",
+   hisi_hba->id, addr);
+   }
+
+   if (ecc_int & SAS_ECC_INTR_ITCT_ECCBAD_MSK) {
+   u32 addr = (hisi_sas_read32(hisi_hba, HGC_ITCT_ECC_ADDR) &
+   HGC_ITCT_ECC_ADDR_BAD_MSK) >>
+   HGC_ITCT_ECC_ADDR_BAD_OFF;
+
+   panic("Fatal TCT RAM ECC interrupt on controller %d @ 0x%08x\n",
+   hisi_hba->id, addr);
+   }
+
+   if (ecc_int & SAS_ECC_INTR_ITCT_ECC1B_MSK) {
+   u32 ecc_err = hisi_sas_read32(hisi_hba, HGC_ECC_ERR);
+
+   panic("Fatal ITCT 1b ECC interrupt on controller %d (0x%x)\n",
+   hisi_hba->id, ecc_err);
+   }
+
+   hisi_sas_write32(hisi_hba, SAS_ECC_INTR, ecc_int | 0x3f);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t fatal_axi_int_v1_hw(int irq, void *p)
+{
+   struct hisi_hba *hisi_hba = p;
+   u32 axi_int = hisi_sas_read32(hisi_hba, ENT_INT_SRC2);
+   u32 axi_info = hisi_sas_read32(hisi_hba, HGC_AXI_FIFO_ERR_INFO);
+
+   if (axi_int & ENT_INT_SRC2_DQ_CFG_ERR_MSK)
+   panic("Fatal DQ_CFG_ERR interrupt on controller %d (0x%x)\n",
+   hisi_hba->id, axi_info);
+
+   if (axi_int & ENT_INT_SRC2_CQ_CFG_ERR_MSK)
+   panic("Fatal CQ_CFG_ERR interrupt on controller %d (0x%x)\n",
+   hisi_hba->id, axi_info);
+
+   if (axi_int & ENT_INT_SRC2_AXI_WRONG_INT_MSK)
+   panic("Fatal AXI_WRONG_INT interrupt on controller %d (0x%x)\n",
+   hisi_hba->id, axi_info);
+
+   if (axi_int & ENT_INT_SRC2_AXI_OVERLF_INT_MSK)
+   panic("Fatal AXI_OVERLF_INT incorrect interrupt on controller 
%d (0x%x)\n",
+   hisi_hba->id, axi_info);
+
+   hisi_sas_write32(hisi_hba, ENT_INT_SRC2, axi_int | 0x3000);
+
+   return IRQ_HANDLED;
+}
+
 static const char phy_int_names[HISI_SAS_PHY_INT_NR][32] = {
{"Bcast"},
{"Phy Up"},
@@ -1628,6 +1713,10 @@ static const char phy_int_names[HISI_SAS_PHY_INT_NR][32] 
= {
 };
 
 static const char cq_int_name[32] = "cq";
+static const char fatal_int_name[HISI_SAS_FATAL_INT_NR][32] = {
+   "fatal ecc",
+   "fatal axi"
+};
 
 static irq_handler_t phy_interrupts[HISI_SAS_PHY_INT_NR] = {
int_bcast_v1_hw,
@@ -1635,6 +1724,11 @@ static irq_handler_t phy_interrupts[HISI_SAS_PHY_INT_NR] 
= {
int_abnormal_v1_hw
 };
 
+static irq_handler_t fatal_interrupts[HISI_SAS_MAX_QUEUES] = {
+   fatal_ecc_int_v1_hw,
+   fatal_axi_int_v1_hw
+};
+
 int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
 {
int i, j, irq, rc, id = hisi_hba->id;
@@ -1697,6 +1791,30 @@ int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)
idx++;
}
 
+   for (i = 0; i < HISI_SAS_FATAL_INT_NR; i++) {
+   int idx = (hisi_hba->n_phy * HISI_SAS_PHY_INT_NR) +
+   hisi_hba->queue_count + i;
+
+   irq = irq_of_parse_and_map(np, idx);
+   if (!irq) {
+   dev_

[PATCH 23/25] scsi: hisi_sas: add control phy handler

2015-10-12 Thread John Garry
Add method for lldd_control_phy. Currently link rate
control and spinup hold is unsupported.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |  7 
 drivers/scsi/hisi_sas/hisi_sas_init.c  |  1 +
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 64 ++
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 22 
 4 files changed, 94 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index b488fe3..be91b8c 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -133,6 +133,7 @@ struct hisi_sas_tei {
 };
 
 enum hisi_sas_wq_event {
+   CONTROL_PHY,
PHYUP,
 };
 
@@ -360,6 +361,9 @@ void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
 int hisi_sas_dev_found(struct domain_device *dev);
 void hisi_sas_dev_gone(struct domain_device *dev);
 int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags);
+int hisi_sas_control_phy(struct asd_sas_phy *sas_phy,
+   enum phy_func func,
+   void *funcdata);
 int hisi_sas_abort_task(struct sas_task *task);
 int hisi_sas_abort_task_set(struct domain_device *dev, u8 *lun);
 int hisi_sas_clear_aca(struct domain_device *dev, u8 *lun);
@@ -375,6 +379,7 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, 
struct sas_task *task,
struct hisi_sas_slot *slot);
 
 /* hw specific functions */
+extern void hard_phy_reset_v1_hw(struct hisi_hba *hisi_hba, int phy_no);
 extern int slot_complete_v1_hw(struct hisi_hba *hisi_hba,
   struct hisi_sas_slot *slot,
   int abort);
@@ -392,8 +397,10 @@ extern int interrupt_openall_v1_hw(struct hisi_hba 
*hisi_hba);
 extern int hw_init_v1_hw(struct hisi_hba *hisi_hba);
 extern int free_device_v1_hw(struct hisi_hba *hisi_hba,
 struct hisi_sas_device *dev);
+extern void enable_phy_v1_hw(struct hisi_hba *hisi_hba, int phy_no);
 extern int phys_init_v1_hw(struct hisi_hba *hisi_hba);
 extern void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no);
 extern void setup_itct_v1_hw(struct hisi_hba *hisi_hba,
 struct hisi_sas_device *device);
+extern void disable_phy_v1_hw(struct hisi_hba *hisi_hba, int phy_no);
 #endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index b6272d8..af4d613e1 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -38,6 +38,7 @@ static struct sas_domain_function_template 
hisi_sas_transport_ops = {
.lldd_dev_found = hisi_sas_dev_found,
.lldd_dev_gone  = hisi_sas_dev_gone,
.lldd_execute_task  = hisi_sas_queue_command,
+   .lldd_control_phy   = hisi_sas_control_phy,
.lldd_abort_task= hisi_sas_abort_task,
.lldd_abort_task_set= hisi_sas_abort_task_set,
.lldd_clear_aca = hisi_sas_clear_aca,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 12af29c..1e42611 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -472,6 +472,32 @@ int hisi_sas_scan_finished(struct Scsi_Host *shost, 
unsigned long time)
return 1;
 }
 
+static void hisi_sas_control_phy_work(struct hisi_hba *hisi_hba,
+   int func,
+   int phy_no)
+{
+   struct device *dev = &hisi_hba->pdev->dev;
+
+   switch (func) {
+   case PHY_FUNC_HARD_RESET:
+   hard_phy_reset_v1_hw(hisi_hba, phy_no);
+   break;
+
+   case PHY_FUNC_LINK_RESET:
+   enable_phy_v1_hw(hisi_hba, phy_no);
+   hard_phy_reset_v1_hw(hisi_hba, phy_no);
+   break;
+
+   case PHY_FUNC_DISABLE:
+   disable_phy_v1_hw(hisi_hba, phy_no);
+   break;
+
+   case PHY_FUNC_SET_LINK_RATE:
+   case PHY_FUNC_RELEASE_SPINUP_HOLD:
+   default:
+   dev_err(dev, "Control phy func %d unsupported\n", func);
+   }
+}
 
 static void hisi_sas_phyup_work(struct hisi_hba *hisi_hba,
  int phy_no)
@@ -487,8 +513,12 @@ void hisi_sas_wq_process(struct work_struct *work)
struct hisi_hba *hisi_hba = wq->hisi_hba;
int event = wq->event;
int phy_no = wq->phy_no;
+   int func = wq->data;
 
switch (event) {
+   case CONTROL_PHY:
+   hisi_sas_control_phy_work(hisi_hba, func, phy_no);
+   break;
case PHYUP:
hisi_sas_phyup_work(hisi_hba, phy_no);
break;
@@ -681,6 +711,40 @@ int hisi_sas_queue_command(struct sas_task *task, gfp_t 
gfp_flags)
return hisi_sas_task_exec(task, gfp_flags, NULL, 0, NULL);
 }
 
+int hisi_sas_control_phy(struct asd_sas_phy *sas_phy,
+   enum phy_func func,
+

[PATCH 14/25] scsi: hisi_sas: add ssp command function

2015-10-12 Thread John Garry
Add path to send ssp command to HW.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |  23 +++
 drivers/scsi/hisi_sas/hisi_sas_init.c  |   1 +
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 246 +
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 206 +++
 4 files changed, 476 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 802c000..908baf3 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -33,6 +33,7 @@
 #define HISI_SAS_COMMAND_TABLE_SZ \
(((sizeof(union hisi_sas_command_table)+3)/4)*4)
 
+#define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024)
 #define HISI_SAS_NAME_LEN 32
 #define HISI_SAS_RESET_REG_CNT 5
 
@@ -109,6 +110,20 @@ struct hisi_sas_slot {
dma_addr_t sge_page_dma;
 };
 
+struct hisi_sas_tmf_task {
+   u8 tmf;
+   u16 tag_of_task_to_be_managed;
+};
+
+struct hisi_sas_tei {
+   struct sas_task *task;
+   struct hisi_sas_cmd_hdr *hdr;
+   struct hisi_sas_port*port;
+   struct hisi_sas_slot*slot;
+   int n_elem;
+   int iptt;
+};
+
 enum hisi_sas_wq_event {
PHYUP,
 };
@@ -158,9 +173,11 @@ struct hisi_hba {
struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES];
struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS];
struct hisi_sas_port port[HISI_SAS_MAX_PHYS];
+
int id;
int queue_count;
char*int_names;
+   struct hisi_sas_slot*slot_prep;
 
struct hisi_sas_device  devices[HISI_SAS_MAX_DEVICES];
struct dma_pool *command_table_pool;
@@ -328,7 +345,13 @@ union hisi_sas_command_table {
 
 void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba);
 void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
+int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags);
 void hisi_sas_wq_process(struct work_struct *work);
+extern void start_delivery_v1_hw(struct hisi_hba *hisi_hba);
+extern int get_free_slot_v1_hw(struct hisi_hba *hisi_hba, int *q, int *s);
+extern int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
+ struct hisi_sas_tei *tei, int is_tmf,
+ struct hisi_sas_tmf_task *tmf);
 extern int interrupt_init_v1_hw(struct hisi_hba *hisi_hba);
 extern int interrupt_openall_v1_hw(struct hisi_hba *hisi_hba);
 extern int hw_init_v1_hw(struct hisi_hba *hisi_hba);
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index 67bfa58..c681b21 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -33,6 +33,7 @@ static struct scsi_host_template hisi_sas_sht = {
 };
 
 static struct sas_domain_function_template hisi_sas_transport_ops = {
+   .lldd_execute_task  = hisi_sas_queue_command,
 };
 
 static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 72831db..3a82262 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -12,6 +12,14 @@
 #include "hisi_sas.h"
 
 
+#define DEV_IS_GONE(dev) \
+   ((!dev) || (dev->dev_type == SAS_PHY_UNUSED))
+
+static struct hisi_hba *dev_to_hisi_hba(struct domain_device *device)
+{
+   return device->port->ha->lldd_ha;
+}
+
 static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx)
 {
void *bitmap = hisi_hba->slot_index_tags;
@@ -19,6 +27,31 @@ static void hisi_sas_slot_index_clear(struct hisi_hba 
*hisi_hba, int slot_idx)
clear_bit(slot_idx, bitmap);
 }
 
+static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx)
+{
+   hisi_sas_slot_index_clear(hisi_hba, slot_idx);
+}
+
+static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx)
+{
+   void *bitmap = hisi_hba->slot_index_tags;
+
+   set_bit(slot_idx, bitmap);
+}
+
+static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, int *slot_idx)
+{
+   unsigned int index;
+   void *bitmap = hisi_hba->slot_index_tags;
+
+   index = find_first_zero_bit(bitmap, hisi_hba->slot_index_count);
+   if (index >= hisi_hba->slot_index_count)
+   return -SAS_QUEUE_FULL;
+   hisi_sas_slot_index_set(hisi_hba, index);
+   *slot_idx = index;
+   return 0;
+}
+
 void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
 {
int i;
@@ -28,6 +61,214 @@ void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
 }
 
 
+static int hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba,
+ struct hisi_sas_tei *tei, int is_tmf,
+ struct hisi_sas_tmf_task *tmf)
+{
+   return prep_ssp_v1_hw(hisi_hba, tei, is_tmf, tmf);
+}
+
+static int hisi_sas_task_prep(struct sas_task *task,
+   struct hisi_hba *hisi_hba,
+

[PATCH 19/25] scsi: hisi_sas: add bcast interrupt handler

2015-10-12 Thread John Garry
This is for expander broadcast event.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 2de54a7..2ad2ffa 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -1370,6 +1370,35 @@ end:
return res;
 }
 
+static irqreturn_t int_bcast_v1_hw(int irq, void *p)
+{
+   struct hisi_sas_phy *phy = p;
+   struct hisi_hba *hisi_hba = phy->hisi_hba;
+   u32 irq_value;
+   irqreturn_t res = IRQ_HANDLED;
+   struct asd_sas_phy *sas_phy = &phy->sas_phy;
+   int phy_no = sas_phy->id;
+   struct sas_ha_struct *sha = &hisi_hba->sha;
+   struct device *dev = &hisi_hba->pdev->dev;
+
+   irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT2);
+
+   if (!(irq_value & CHL_INT2_SL_RX_BC_ACK_MSK)) {
+   dev_err(dev, "bcast: irq_value = %x not set enable bit",
+   irq_value);
+   res = IRQ_NONE;
+   goto end;
+   }
+
+   sha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
+
+end:
+   hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2,
+   CHL_INT2_SL_RX_BC_ACK_MSK);
+
+   return res;
+}
+
 static irqreturn_t int_abnormal_v1_hw(int irq, void *p)
 {
struct hisi_sas_phy *phy = p;
@@ -1478,6 +1507,7 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p)
 }
 
 static const char phy_int_names[HISI_SAS_PHY_INT_NR][32] = {
+   {"Bcast"},
{"Phy Up"},
{"Abnormal"},
 };
@@ -1485,6 +1515,7 @@ static const char phy_int_names[HISI_SAS_PHY_INT_NR][32] 
= {
 static const char cq_int_name[32] = "cq";
 
 static irq_handler_t phy_interrupts[HISI_SAS_PHY_INT_NR] = {
+   int_bcast_v1_hw,
int_phyup_v1_hw,
int_abnormal_v1_hw
 };
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/25] scsi: hisi_sas: add v1 HW initialisation code

2015-10-12 Thread John Garry
Add complete code to initialise HW to the point where
we can get a phy up interrupt when a disk is connected.

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |  10 +
 drivers/scsi/hisi_sas/hisi_sas_init.c  |  20 ++
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 502 +
 3 files changed, 532 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 1a26f27..18fd30b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -34,7 +34,12 @@
(((sizeof(union hisi_sas_command_table)+3)/4)*4)
 
 #define HISI_SAS_NAME_LEN 32
+#define HISI_SAS_RESET_REG_CNT 5
 
+enum {
+   PORT_TYPE_SAS = (1U << 1),
+   PORT_TYPE_SATA = (1U << 0),
+};
 
 enum dev_status {
HISI_SAS_DEV_NORMAL,
@@ -123,6 +128,7 @@ struct hisi_hba {
 
void __iomem *regs;
void __iomem *ctrl_regs;
+   u32 reset_reg[HISI_SAS_RESET_REG_CNT];
 
u8 sas_addr[SAS_ADDR_SIZE];
 
@@ -323,4 +329,8 @@ union hisi_sas_command_table {
 void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba);
 void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i);
 void hisi_sas_wq_process(struct work_struct *work);
+extern int interrupt_init_v1_hw(struct hisi_hba *hisi_hba);
+extern int interrupt_openall_v1_hw(struct hisi_hba *hisi_hba);
+extern int hw_init_v1_hw(struct hisi_hba *hisi_hba);
+extern int phys_init_v1_hw(struct hisi_hba *hisi_hba);
 #endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index 558e0e7..67bfa58 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -270,6 +270,11 @@ static struct hisi_hba *hisi_sas_hba_alloc(
 
init_timer(&hisi_hba->timer);
 
+   if (of_property_read_u32_array(np, "reset-reg",
+  (u32 *) &hisi_hba->reset_reg,
+  HISI_SAS_RESET_REG_CNT))
+   goto err_out;
+
if (of_property_read_u32(np, "phy-count", &hisi_hba->n_phy))
goto err_out;
 
@@ -387,6 +392,21 @@ static int hisi_sas_probe(struct platform_device *pdev)
}
 
hisi_sas_init_add(hisi_hba);
+
+   rc = hw_init_v1_hw(hisi_hba);
+   if (rc)
+   goto err_out_ha;
+
+   rc = interrupt_init_v1_hw(hisi_hba);
+   if (rc)
+   goto err_out_ha;
+
+   rc = interrupt_openall_v1_hw(hisi_hba);
+   if (rc)
+   goto err_out_ha;
+
+   phys_init_v1_hw(hisi_hba);
+
rc = scsi_add_host(shost, &pdev->dev);
if (rc)
goto err_out_ha;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index ccc7aa7..20291b4 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -400,3 +400,505 @@ enum {
(HISI_SAS_PHY_MAX_INT_NR + HISI_SAS_CQ_MAX_INT_NR +\
HISI_SAS_FATAL_INT_NR)
 
+static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off)
+{
+   void __iomem *regs = hisi_hba->regs + off;
+
+   return readl(regs);
+}
+
+static void hisi_sas_write32(struct hisi_hba *hisi_hba,
+   u32 off, u32 val)
+{
+   void __iomem *regs = hisi_hba->regs + off;
+
+   writel(val, regs);
+}
+
+static void hisi_sas_phy_write32(struct hisi_hba *hisi_hba,
+   int phy_no, u32 off, u32 val)
+{
+   void __iomem *regs = hisi_hba->regs + (0x400 * phy_no) + off;
+
+   writel(val, regs);
+}
+
+static u32 hisi_sas_phy_read32(struct hisi_hba *hisi_hba,
+ int phy_no, u32 off)
+{
+   void __iomem *regs = hisi_hba->regs + (0x400 * phy_no) + off;
+
+   return readl(regs);
+}
+
+static void config_phy_opt_mode_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
+{
+   u32 cfg = hisi_sas_phy_read32(hisi_hba, phy_no, PHY_CFG);
+
+   cfg &= ~PHY_CFG_DC_OPT_MSK;
+   cfg |= 1 << PHY_CFG_DC_OPT_OFF;
+   hisi_sas_phy_write32(hisi_hba, phy_no, PHY_CFG, cfg);
+}
+
+static void config_tx_tfe_autoneg_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
+{
+   u32 cfg = hisi_sas_phy_read32(hisi_hba, phy_no, PHY_CONFIG2);
+
+   cfg &= ~PHY_CONFIG2_FORCE_TXDEEMPH_MSK;
+   hisi_sas_phy_write32(hisi_hba, phy_no, PHY_CONFIG2, cfg);
+}
+
+static void config_id_frame_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
+{
+   struct sas_identify_frame identify_frame;
+   u32 *identify_buffer;
+
+   memset(&identify_frame, 0, sizeof(identify_frame));
+   identify_frame.dev_type = SAS_END_DEVICE;
+   identify_frame.frame_type = 0;
+   identify_frame._un1 = 1;
+   identify_frame.initiator_bits = SAS_PROTOCOL_ALL;
+   identify_frame.target_bits = SAS_PROTOCOL_NONE;
+   memcpy(&identify_frame._un4_11[0], hisi_hba->sas_addr, SAS_ADDR_SIZE);
+   memcpy(&identify_frame.sas_addr[0], hisi_hba->sas_addr, SAS_ADDR_SIZE);

[PATCH 13/25] scsi: hisi_sas: add path from phyup irq to SAS framework

2015-10-12 Thread John Garry
Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas.h   |  1 +
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 55 ++
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 24 +++
 3 files changed, 80 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 18fd30b..802c000 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -333,4 +333,5 @@ extern int interrupt_init_v1_hw(struct hisi_hba *hisi_hba);
 extern int interrupt_openall_v1_hw(struct hisi_hba *hisi_hba);
 extern int hw_init_v1_hw(struct hisi_hba *hisi_hba);
 extern int phys_init_v1_hw(struct hisi_hba *hisi_hba);
+extern void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no);
 #endif
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 882ff79..72831db 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -27,10 +27,65 @@ void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
hisi_sas_slot_index_clear(hisi_hba, i);
 }
 
+
+void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int phy_no)
+{
+   struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
+   struct asd_sas_phy *sas_phy = &phy->sas_phy;
+   struct sas_ha_struct *sas_ha;
+
+   if (!phy->phy_attached)
+   return;
+
+   sas_ha = &hisi_hba->sha;
+   sas_ha->notify_phy_event(sas_phy, PHYE_OOB_DONE);
+
+   if (sas_phy->phy) {
+   struct sas_phy *sphy = sas_phy->phy;
+
+   sphy->negotiated_linkrate = sas_phy->linkrate;
+   sphy->minimum_linkrate = phy->minimum_linkrate;
+   sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
+   sphy->maximum_linkrate = phy->maximum_linkrate;
+   }
+
+   if (phy->phy_type & PORT_TYPE_SAS) {
+   struct sas_identify_frame *id;
+
+   id = (struct sas_identify_frame *)phy->frame_rcvd;
+   id->dev_type = phy->identify.device_type;
+   id->initiator_bits = SAS_PROTOCOL_ALL;
+   id->target_bits = phy->identify.target_port_protocols;
+   } else if (phy->phy_type & PORT_TYPE_SATA) {
+   /*Nothing*/
+   }
+
+   sas_phy->frame_rcvd_size = phy->frame_rcvd_size;
+
+   sas_ha->notify_port_event(sas_phy, PORTE_BYTES_DMAED);
+}
+
+
+static void hisi_sas_phyup_work(struct hisi_hba *hisi_hba,
+ int phy_no)
+{
+   sl_notify_v1_hw(hisi_hba, phy_no); /* This requires a sleep */
+   hisi_sas_bytes_dmaed(hisi_hba, phy_no);
+}
+
 void hisi_sas_wq_process(struct work_struct *work)
 {
struct hisi_sas_wq *wq =
container_of(work, struct hisi_sas_wq, work_struct);
+   struct hisi_hba *hisi_hba = wq->hisi_hba;
+   int event = wq->event;
+   int phy_no = wq->phy_no;
+
+   switch (event) {
+   case PHYUP:
+   hisi_sas_phyup_work(hisi_hba, phy_no);
+   break;
+   }
 
kfree(wq);
 }
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 20291b4..df56b3a 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -738,6 +738,19 @@ int phys_init_v1_hw(struct hisi_hba *hisi_hba)
return 0;
 }
 
+void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
+{
+   u32 sl_control;
+
+   sl_control = hisi_sas_phy_read32(hisi_hba, phy_no, SL_CONTROL);
+   sl_control |= SL_CONTROL_NOTIFY_EN_MSK;
+   hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control);
+   msleep(1);
+   sl_control = hisi_sas_phy_read32(hisi_hba, phy_no, SL_CONTROL);
+   sl_control &= ~SL_CONTROL_NOTIFY_EN_MSK;
+   hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control);
+}
+
 /* Interrupts */
 static irqreturn_t int_phyup_v1_hw(int irq_no, void *p)
 {
@@ -750,6 +763,7 @@ static irqreturn_t int_phyup_v1_hw(int irq_no, void *p)
struct sas_identify_frame *id = (struct sas_identify_frame *)frame_rcvd;
u32 irq_value, context, port_id, link_rate;
int i;
+   struct hisi_sas_wq *wq = NULL;
irqreturn_t res = IRQ_HANDLED;
 
irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT2);
@@ -804,6 +818,16 @@ static irqreturn_t int_phyup_v1_hw(int irq_no, void *p)
phy->identify.target_port_protocols =
SAS_PROTOCOL_SMP;
 
+   wq = kmalloc(sizeof(*wq), GFP_ATOMIC);
+   if (!wq)
+   goto end;
+
+   wq->event = PHYUP;
+   wq->hisi_hba = hisi_hba;
+   wq->phy_no = phy_no;
+
+   INIT_WORK(&wq->work_struct, hisi_sas_wq_process);
+   queue_work(hisi_hba->wq, &wq->work_struct);
 
 end:
hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger

[PATCH 09/25] scsi: hisi_sas: add phy SAS ADDR initialization

2015-10-12 Thread John Garry
This SAS ID is chosen as Huawei IEEE id: 001882

Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_init.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_init.c 
b/drivers/scsi/hisi_sas/hisi_sas_init.c
index 44fc524..c295c39 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_init.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_init.c
@@ -283,6 +283,19 @@ err_out:
return NULL;
 }
 
+static void hisi_sas_init_add(struct hisi_hba *hisi_hba)
+{
+   u8 i;
+
+   /* Huawei IEEE id (001882) */
+   for (i = 0; i < hisi_hba->n_phy; i++)
+   hisi_hba->phy[i].dev_sas_addr =
+   cpu_to_be64(0x5001882016072015ULL);
+
+   memcpy(hisi_hba->sas_addr, &hisi_hba->phy[0].dev_sas_addr,
+  SAS_ADDR_SIZE);
+}
+
 static int hisi_sas_probe(struct platform_device *pdev)
 {
struct Scsi_Host *shost;
@@ -339,6 +352,8 @@ static int hisi_sas_probe(struct platform_device *pdev)
sha->sas_phy[i] = &hisi_hba->phy[i].sas_phy;
sha->sas_port[i] = &hisi_hba->port[i].sas_port;
}
+
+   hisi_sas_init_add(hisi_hba);
rc = scsi_add_host(shost, &pdev->dev);
if (rc)
goto err_out_ha;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/25] HiSilicon SAS driver

2015-10-12 Thread John Garry
This is the driver patchset for the HiSilicon SAS driver. The driver
is a platform driver.

The driver will support multiple revisions of HW. Currently only "v1"
HW is supported.

The driver uses libsas framework within the SCSI framework.

The v1 HW supports SSP and SMP, but not STP/SATA.


John Garry (25):
  [SCSI] sas: centralise ssp frame information units
  devicetree: bindings: scsi: HiSi SAS
  scsi: hisi_sas: add initial bare driver
  scsi: hisi_sas: add scsi host registration
  scsi: hisi_sas: allocate memories and create pools
  scsi: hisi_sas: add slot init code
  scsi: hisi_sas: add ioremap for device HW
  scsi: hisi_sas: add cq structure initialization
  scsi: hisi_sas: add phy SAS ADDR initialization
  scsi: hisi_sas: add misc HBA initialization
  scsi: hisi_sas: add v1 hardware register definitions
  scsi: hisi_sas: add v1 HW initialisation code
  scsi: hisi_sas: add path from phyup irq to SAS framework
  scsi: hisi_sas: add ssp command function
  scsi: hisi_sas: add cq interrupt handler
  scsi: hisi_sas: add dev_found and port_formed
  scsi: hisi_sas: add abnormal irq handler
  scsi: hisi_sas: add dev_gone and port_deformed
  scsi: hisi_sas: add bcast interrupt handler
  scsi: hisi_sas: add smp protocol support
  scsi: hisi_sas: add scan finished and start
  scsi: hisi_sas: add tmf methods
  scsi: hisi_sas: add control phy handler
  scsi: hisi_sas: add fatal irq handler
  MAINTAINERS: add maintainer for HiSi SAS driver

 .../devicetree/bindings/scsi/hisilicon-sas.txt |   63 +
 MAINTAINERS|7 +
 drivers/scsi/Kconfig   |1 +
 drivers/scsi/Makefile  |1 +
 drivers/scsi/aic94xx/aic94xx_sas.h |   49 +-
 drivers/scsi/hisi_sas/Kconfig  |5 +
 drivers/scsi/hisi_sas/Makefile |2 +
 drivers/scsi/hisi_sas/hisi_sas.h   |  406 +
 drivers/scsi/hisi_sas/hisi_sas_init.c  |  489 ++
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 1115 
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 1850 
 include/scsi/sas.h |   74 +
 12 files changed, 4019 insertions(+), 43 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/scsi/hisilicon-sas.txt
 create mode 100644 drivers/scsi/hisi_sas/Kconfig
 create mode 100644 drivers/scsi/hisi_sas/Makefile
 create mode 100644 drivers/scsi/hisi_sas/hisi_sas.h
 create mode 100644 drivers/scsi/hisi_sas/hisi_sas_init.c
 create mode 100644 drivers/scsi/hisi_sas/hisi_sas_main.c
 create mode 100644 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] st: allow debug output to be enabled or disabled via sysfs

2015-10-12 Thread Laurence Oberman
I support this addition as it can be done without the module reload
provided by my prior patch.

Reviewed-by: Laurence Oberman 

On Mon, Oct 12, 2015 at 12:31 AM, Seymour, Shane M
 wrote:
>
> Change st driver to allow enabling or disabling debug output
> via sysfs file /sys/bus/scsi/drivers/st/debug_flag.
>
> Previously the only way to enable debug output was:
>
> 1. loading the driver with the module parameter debug_flag=1
> 2. an ioctl call (this method was also the only way to dynamically
> disable debug output).
>
> To use the ioctl you need a second tape drive (if you are
> actively testing the first tape drive) since a second process
> cannot open the first tape drive if it is in use.
>
> The this change is only functional if the value of the macro
> DEBUG in st.c is a non-zero value (which it is by default).
>
> Signed-off-by: Shane Seymour 
> ---
> --- a/drivers/scsi/st.c 2015-10-06 17:11:16.299801789 -0500
> +++ b/drivers/scsi/st.c 2015-10-11 14:45:10.595060995 -0500
> @@ -4452,11 +4452,41 @@ static ssize_t version_show(struct devic
>  }
>  static DRIVER_ATTR_RO(version);
>
> +#if DEBUG
> +static ssize_t debug_flag_store(struct device_driver *ddp,
> +   const char *buf, size_t count)
> +{
> +/* We only care what the first byte of the data is the rest is unused.
> + * if it's a '1' we turn on debug and if it's a '0' we disable it. All
> + * other values have -EINVAL returned if they are passed in.
> + */
> +   if (count > 0) {
> +   if (buf[0] == '0') {
> +   debugging = NO_DEBUG;
> +   return count;
> +   } else if (buf[0] == '1') {
> +   debugging = 1;
> +   return count;
> +   }
> +   }
> +   return -EINVAL;
> +}
> +
> +static ssize_t debug_flag_show(struct device_driver *ddp, char *buf)
> +{
> +   return scnprintf(buf, PAGE_SIZE, "%d\n", debugging);
> +}
> +static DRIVER_ATTR_RW(debug_flag);
> +#endif
> +
>  static struct attribute *st_drv_attrs[] = {
> &driver_attr_try_direct_io.attr,
> &driver_attr_fixed_buffer_size.attr,
> &driver_attr_max_sg_segs.attr,
> &driver_attr_version.attr,
> +#if DEBUG
> +   &driver_attr_debug_flag.attr,
> +#endif
> NULL,
>  };
>  ATTRIBUTE_GROUPS(st_drv);
> diff -uprN a/Documentation/ABI/testing/sysfs-driver-st 
> b/Documentation/ABI/testing/sysfs-driver-st
> --- a/Documentation/ABI/testing/sysfs-driver-st 1969-12-31 18:00:00.0 
> -0600
> +++ b/Documentation/ABI/testing/sysfs-driver-st 2015-10-11 14:28:43.537128220 
> -0500
> @@ -0,0 +1,12 @@
> +What:  /sys/bus/scsi/drivers/st/debug_flag
> +Date:  October 2015
> +Kernel Version:?.?
> +Contact:   shane.seym...@hpe.com
> +Description:
> +   This file allows you to turn debug output from the st driver
> +   off if you write a '0' to the file or on if you write a '1'.
> +   Note that debug output requires that the module be compiled
> +   with the #define DEBUG set to a non-zero value (this is the
> +   default). If DEBUG is set to 0 then this file will not
> +   appear in sysfs as its presence is conditional upon debug
> +   output support being compiled into the module.
> --- a/Documentation/scsi/st.txt 2015-10-06 17:11:12.323802060 -0500
> +++ b/Documentation/scsi/st.txt 2015-10-11 14:19:48.176164681 -0500
> @@ -569,7 +569,9 @@ Debugging code is now compiled in by def
>  with the kernel module parameter debug_flag defaulting to 0.  Debugging
>  can still be switched on and off with an ioctl.  To enable debug at
>  module load time add debug_flag=1 to the module load options, the
> -debugging output is not voluminous.
> +debugging output is not voluminous. Debugging can also be enabled
> +and disabled by writing a '0' (disable) or '1' (enable) to the sysfs
> +file /sys/bus/scsi/drivers/st/debug_flag.
>
>  If the tape seems to hang, I would be very interested to hear where
>  the driver is waiting. With the command 'ps -l' you can see the state
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: SSP frame iu defines

2015-10-12 Thread James Bottomley
On Thu, 2015-10-08 at 15:47 +0100, John Garry wrote:
> On 08/10/2015 15:22, Arnd Bergmann wrote:
> > On Thursday 08 October 2015 15:17:49 John Garry wrote:
> >> Hi,
> >>
> >> For a new driver I am preparing for a SAS controller, I need defintions
> >> for the SSP command and TMF iu structures. Currently these are defined
> >> in the following:
> >> ssp_command_iu, ssp_task_iu: drivers/scsi/aic94xx_sas.h
> >> ssp_cmd_iu, ssp_task_iu: drivers/scsi/isci/sas.h
> >>
> >> I plan to move them to include/scsi/sas.h . Any objections?
> >
> > Hi John,
> >
> > I think a question like this is better asked by sending a patch,
> > to make it easier to see what the resulting change is.
> >
> > Arnd
> >
> >
> OK, can I put this together.
> I feel that the code may get messy due to byte-ordering difference in 
> isci versions.

That's why we develop with the show me the code model.  Rather than
arguing theoretically about whether something should or should not be
done, you propose the actual change.  If it looks like a dog's breakfast
and all attempts to clean it up fail, chances are it's a bad change and
it won't go in.  However, if it looks good, chances are it will.

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bugs in multipath scsi in 4.3-rc2

2015-10-12 Thread James Bottomley
On Mon, 2015-10-12 at 14:45 +0200, Hannes Reinecke wrote:
> On 10/04/2015 09:45 AM, Christoph Hellwig wrote:
> > On Fri, Oct 02, 2015 at 06:44:57AM -0700, James Bottomley wrote:
> >> I think I prefer restoring that to having to build in every dh module to
> >> get them to work.  If we take your proposed fix for the sync module load
> >> in the current scheme, any non-built in modules would never attach, so
> >> we'd be moving towards the conclusion that *every* device handler has to
> >> be non-modular.
> > 
> > You don't need to build every module in to make it work.  In 4.2 and earlier
> > we already only auto load modules when dm-multipath explicitly attaches
> > to them.  That will still work in 4.3+.  In fact we will now autoload
> > when activating through sysfs as well.  With the change I sent to Paul
> > we still won't autoload at scan time, which would be really useful to have,
> > but wasn't implemented previously.
> > 
> >> Skimming the code it looks like dh should be using the driver binding
> >> model rather than reinventing it.  That would decouple it better and
> >> make sure binding happened regardless of when the module was loaded.
> > 
> > I tried this early on but gave up because I ran into too many problems.
> > I can try to give it a spin again.
> 
> You cannot easily use the driver model here as the scsi_device is
> already (potentially) bound to the ULDs.
> If you were to go with the driver model you'd have to introduce
> another sub device between scsi_target and scsi_device.

I was thinking more like what we do today for the ULD's: 3 of them use
the driver binding and one uses the class interface model.  Why can't we
also use the class interface model for dh?

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bugs in multipath scsi in 4.3-rc2

2015-10-12 Thread Christoph Hellwig
On Mon, Oct 12, 2015 at 02:45:38PM +0200, Hannes Reinecke wrote:
> You cannot easily use the driver model here as the scsi_device is
> already (potentially) bound to the ULDs.
> If you were to go with the driver model you'd have to introduce
> another sub device between scsi_target and scsi_device.

You can have two struct devices in struct scsi_device, while it's
not pretty there are plenty of example all over the kernel with
multiple devices in a single containing structure. 

> Actually I have been thinking that, as it might make my life for the
> ALUA handler easier. However, this would be quite a largish redesign
> of the current handler infrastructure, pushing out my ALUA handler
> update even more.
> So I'd like to have the ALUA changes ironed out first and merged,
> and then work on a redesigned device handler infrastructure.

Fine with me.  As mentioned before we've never supported autoloading
the device handler modules at boot time - we only ever loaded them when
explicitly attaching them through device mapper.  Waiting another
release or maybe two to finally get there isn't the end of the world.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: SSP frame iu defines

2015-10-12 Thread Hannes Reinecke
On 10/08/2015 04:47 PM, John Garry wrote:
> On 08/10/2015 15:22, Arnd Bergmann wrote:
>> On Thursday 08 October 2015 15:17:49 John Garry wrote:
>>> Hi,
>>>
>>> For a new driver I am preparing for a SAS controller, I need
>>> defintions
>>> for the SSP command and TMF iu structures. Currently these are
>>> defined
>>> in the following:
>>> ssp_command_iu, ssp_task_iu: drivers/scsi/aic94xx_sas.h
>>> ssp_cmd_iu, ssp_task_iu: drivers/scsi/isci/sas.h
>>>
>>> I plan to move them to include/scsi/sas.h . Any objections?
>>
>> Hi John,
>>
>> I think a question like this is better asked by sending a patch,
>> to make it easier to see what the resulting change is.
>>
>> Arnd
>>
>>
> OK, can I put this together.
> I feel that the code may get messy due to byte-ordering difference
> in isci versions.
> 
Then define a standard version, and use the appropriate conversion
macros in the driver itself.

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bugs in multipath scsi in 4.3-rc2

2015-10-12 Thread Hannes Reinecke
On 10/04/2015 09:45 AM, Christoph Hellwig wrote:
> On Fri, Oct 02, 2015 at 06:44:57AM -0700, James Bottomley wrote:
>> I think I prefer restoring that to having to build in every dh module to
>> get them to work.  If we take your proposed fix for the sync module load
>> in the current scheme, any non-built in modules would never attach, so
>> we'd be moving towards the conclusion that *every* device handler has to
>> be non-modular.
> 
> You don't need to build every module in to make it work.  In 4.2 and earlier
> we already only auto load modules when dm-multipath explicitly attaches
> to them.  That will still work in 4.3+.  In fact we will now autoload
> when activating through sysfs as well.  With the change I sent to Paul
> we still won't autoload at scan time, which would be really useful to have,
> but wasn't implemented previously.
> 
>> Skimming the code it looks like dh should be using the driver binding
>> model rather than reinventing it.  That would decouple it better and
>> make sure binding happened regardless of when the module was loaded.
> 
> I tried this early on but gave up because I ran into too many problems.
> I can try to give it a spin again.

You cannot easily use the driver model here as the scsi_device is
already (potentially) bound to the ULDs.
If you were to go with the driver model you'd have to introduce
another sub device between scsi_target and scsi_device.

Actually I have been thinking that, as it might make my life for the
ALUA handler easier. However, this would be quite a largish redesign
of the current handler infrastructure, pushing out my ALUA handler
update even more.
So I'd like to have the ALUA changes ironed out first and merged,
and then work on a redesigned device handler infrastructure.

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] libfc: correct function name in comment

2015-10-12 Thread Hannes Reinecke
On 10/11/2015 10:35 PM, Sebastian Herbszt wrote:
> Use the correct function name in kernel-doc comment.
> 
> Signed-off-by: Sebastian Herbszt 
> Acked-by: Vasu Dev 
> ---
> 
> diff -U 5 -rp a/drivers/scsi/libfc/fc_npiv.c b/drivers/scsi/libfc/fc_npiv.c
> --- a/drivers/scsi/libfc/fc_npiv.c2014-09-03 19:30:11.760273300 +0200
> +++ b/drivers/scsi/libfc/fc_npiv.c2015-08-05 00:06:17.927753719 +0200
> @@ -23,11 +23,11 @@
>  
>  #include 
>  #include 
>  
>  /**
> - * fc_vport_create() - Create a new NPIV vport instance
> + * libfc_vport_create() - Create a new NPIV vport instance
>   * @vport: fc_vport structure from scsi_transport_fc
>   * @privsize: driver private data size to allocate along with the Scsi_Host
>   */
>  
>  struct fc_lport *libfc_vport_create(struct fc_vport *vport, int privsize)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] scsi: report 'INQUIRY result too short' once per host

2015-10-12 Thread Hannes Reinecke
On 10/08/2015 06:54 PM, Vitaly Kuznetsov wrote:
> Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
> SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
> least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
> INQUIRY result too short (5), using 36' messages on console. This can be
> problematic for slow consoles. Introduce short_inquiry flag in struct
> Scsi_Host to print the message once per host.
> 
> Signed-off-by: Vitaly Kuznetsov 
> ---
> Changes since v2:
> - This is a successor of previously sent (and still not merged) "scsi:
>   introduce short_inquiry flag for broken host adapters" patch. I'm not
>   particularly sure which solution is better but I'm leaning towards this
>   one as it doesn't require changes to adapter drivers.
> ---
>  drivers/scsi/scsi_scan.c | 9 ++---
>  include/scsi/scsi_host.h | 3 +++
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index f9f3f82..cd347e4 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, 
> unsigned char *inq_result,
>* strings.
>*/
>   if (sdev->inquiry_len < 36) {
> - sdev_printk(KERN_INFO, sdev,
> - "scsi scan: INQUIRY result too short (%d),"
> - " using 36\n", sdev->inquiry_len);
> + if (!sdev->host->short_inquiry) {
> + shost_printk(KERN_INFO, sdev->host,
> + "scsi scan: INQUIRY result too short (%d),"
> + " using 36\n", sdev->inquiry_len);
> + sdev->host->short_inquiry = 1;
> + }
>   sdev->inquiry_len = 36;
>   }
>  
At least you need to check if you've received any valid data here;
'INQUIRY result too short' is also a common error if the interrupt
is hosed when trying to access the device.
So please check for 'inquiry_len > 4' before setting 'short_inquiry'.

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: use host wide tags by default

2015-10-12 Thread Hannes Reinecke
On 10/08/2015 10:28 AM, Christoph Hellwig wrote:
> This patch changes the !blk-mq path to the same defaults as the blk-mq
> I/O path by always enabling block tagging, and always using host wide
> tags.  We've had blk-mq available for a few releases so bugs with
> this mode should have been ironed out, and this ensures we get better
> coverage of over tagging setup over different configs.
> 
> Signed-off-by: Christoph Hellwig 
> Acked-by: Jens Axboe 

Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: don't try to load a device handler during async probing

2015-10-12 Thread Hannes Reinecke
On 10/08/2015 10:25 AM, Christoph Hellwig wrote:
> Request_module gets really unhappy when called from async probing, so
> revert to not auto load device handler modules during the SCSI bus
> scan.  While autoloading would be really useful we never did this
> until 4.3-rc and it turns out that functionality doesn't actually
> work.
> 
> Fixes: 566079 ("dm-mpath, scsi_dh: request scsi_dh modules in scsi_dh, not 
> dm-mpath")
> Signed-off-by: Christoph Hellwig 
> Reported-by: Paul Mackerras 
> Tested-by: Paul Mackerras 
> ---
>  drivers/scsi/scsi_dh.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
> index 0a2168e..d771bec 100644
> --- a/drivers/scsi/scsi_dh.c
> +++ b/drivers/scsi/scsi_dh.c
> @@ -226,7 +226,7 @@ int scsi_dh_add_device(struct scsi_device *sdev)
>  
>   drv = scsi_dh_find_driver(sdev);
>   if (drv)
> - devinfo = scsi_dh_lookup(drv);
> + devinfo = __scsi_dh_lookup(drv);
>   if (devinfo)
>   err = scsi_dh_handler_attach(sdev, devinfo);
>   return err;
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html