]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
7 years agoscsi: megaraid_sas: driver version upgrade
Shivasharan S [Thu, 19 Oct 2017 09:49:06 +0000 (02:49 -0700)]
scsi: megaraid_sas: driver version upgrade

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Add support for 64bit consistent DMA
Sumit Saxena [Thu, 1 Mar 2018 12:00:22 +0000 (07:00 -0500)]
scsi: megaraid_sas: Add support for 64bit consistent DMA

The latest MegaRAID Firmware (for Invader series) has support for 64bit
DMA for both streaming and consistent DMA buffers.  All Ventura series
controller FW always support 64 bit consistent DMA.  Also, on a few
architectures 32bit DMA is not supported.

Current driver always prefers 32bit for consistent DMA and 64bit for
streaming DMA.  This behavior was unintentional and carried forwarded
from legacy controller FW. Need to enhance the driver to support 64bit
consistent DMA buffers based on the firmware capability.

Below is the DMA setting strategy in driver with this patch.  For
Ventura series, always try to set 64bit DMA mask. If it fails fall back
to 32bit DMA mask.  For Invader series and earlier generation
controllers, first try to set to 32bit consistent DMA mask irrespective
of FW capability. This is needed to ensure firmware downgrades do not
break. If 32bit DMA setting fails, check FW capability and try seting to
64bit DMA mask.

There are certain restrictions in the hardware for having all sense
buffers and all reply descriptors to be in the same 4GB memory region.
This limitation is h/w dependent and can not be changed in firmware.
This limitation needs to be taken care in driver while allocating the
buffers.  There was a discussion regarding this - find details at below
link.  https://www.spinics.net/lists/linux-scsi/msg108251.html

Rebased this patch for UEK kernel.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Do not limit queue_depth to 1k in non-RDPQ mode
Shivasharan S [Thu, 19 Oct 2017 09:49:04 +0000 (02:49 -0700)]
scsi: megaraid_sas: Do not limit queue_depth to 1k in non-RDPQ mode

Driver load fails if memory allocation for request frame pool fails due
to the higher queue_depth requirement. The driver now allows dynamically
reducing queue_depth if memory allocations fail rather than failing
load.  With this, there is no need to limit queue_depth to 1K.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Retry with reduced queue depth when alloc fails for higher QD
Shivasharan S [Thu, 19 Oct 2017 09:49:03 +0000 (02:49 -0700)]
scsi: megaraid_sas: Retry with reduced queue depth when alloc fails for higher QD

In certain cases, the host memory is limited and with FW supporting
higher queue depths there are increasing chances of IO request frame
allocation failures that we are seeing. In case of request frame
allocation failures, retry allocation with reduced queue depth (in steps
of 64) to continue to configure the controller with a reduced
performance rather than failing load.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Incorrect processing of IOCTL frames for SMP/STP commands
Shivasharan S [Thu, 19 Oct 2017 09:49:02 +0000 (02:49 -0700)]
scsi: megaraid_sas: Incorrect processing of IOCTL frames for SMP/STP commands

cmd->frame->dcmd.opcode will be valid only for MFI_CMD_DCMD
IOCTL frames. Currently driver check for cmd->frame->dcmd.opcode without
checking cmd type. Ensure we check dcmd opcode only for MFI_CMD_DCMD
commands. Separate handling of MFI_CMD_SMP/STP commands from
MFI_CMD_DCMD in completion path.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Resize MFA frame used for IOC INIT to 4k
Shivasharan S [Thu, 19 Oct 2017 09:49:01 +0000 (02:49 -0700)]
scsi: megaraid_sas: Resize MFA frame used for IOC INIT to 4k

Older firmware version unconditionally pulls 4k frame for IOC INIT MFA
frame.  But driver allocates 1k or 4k max_chain_frame_sz based on FW
capability.  During boot time, this results in DMA read errors.
Workaround fix in driver by allocating separate ioc_init frame of 4k
size to support older firmware.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Update current host time to FW during IOC Init
Shivasharan S [Thu, 19 Oct 2017 09:49:00 +0000 (02:49 -0700)]
scsi: megaraid_sas: Update current host time to FW during IOC Init

Driver needs to send current host time to firmware during init.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Move controller memory allocations and DMA mask settings from...
Sumit Saxena [Thu, 1 Mar 2018 11:54:54 +0000 (06:54 -0500)]
scsi: megaraid_sas: Move controller memory allocations and DMA mask settings from probe to megasas_init_fw

Rebased patch for UEK kernel.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Move initialization of instance parameters inside newly created...
Shivasharan S [Thu, 19 Oct 2017 09:48:58 +0000 (02:48 -0700)]
scsi: megaraid_sas: Move initialization of instance parameters inside newly created function megasas_init_ctrl_params

Code refactoring, no functional change. Create new function to
initialize all the controller parameters during load time.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: remove instance->ctrl_info
Sumit Saxena [Thu, 1 Mar 2018 11:50:13 +0000 (06:50 -0500)]
scsi: megaraid_sas: remove instance->ctrl_info

Re-use the pre-allocated ctrl_info DMA buffer.

Rebased patch for UEK kernel.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Pre-allocate frequently used DMA buffers
Shivasharan S [Thu, 19 Oct 2017 09:48:56 +0000 (02:48 -0700)]
scsi: megaraid_sas: Pre-allocate frequently used DMA buffers

Pre-allocate few of the frequently used DMA buffers during load time.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Create separate functions for allocating and freeing controller...
Sumit Saxena [Thu, 1 Mar 2018 11:46:48 +0000 (06:46 -0500)]
scsi: megaraid_sas: Create separate functions for allocating and freeing controller DMA buffers

Code refactoring - create separate functions to allocate and free
controller DMA buffers.

Rebased for UEK kernel.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Create separate functions to allocate ctrl memory
Shivasharan S [Thu, 19 Oct 2017 09:48:54 +0000 (02:48 -0700)]
scsi: megaraid_sas: Create separate functions to allocate ctrl memory

No functional change. Code refactoring to improve readability.  Move the
code to allocate and free controller memory into separate functions.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: reduce size of fusion_context and use kmalloc for allocation
Sumit Saxena [Thu, 1 Mar 2018 11:18:16 +0000 (06:18 -0500)]
scsi: megaraid_sas: reduce size of fusion_context and use kmalloc for allocation

fusion_context structure is very large around 180kB and most of the size
is contributed by log_to_span array. Move log_to_span out of fusion
context and have separate allocation for log_to_span. And use kmalloc to
allocate fusion_context.  Currently kmemleak reports 1000s of false
positives for fusion->cmd_list[]. kmemleak does not track page
allocation for fusion_context. This change will also fix the false
positives reported by kmemleak.

Ref: https://marc.info/?l=linux-scsi&m=150545293900917

Rebased for UEK kernel.

Reported-by: Shu Wang <shuwang@redhat.com>
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: replace is_ventura with adapter_type checks
Sumit Saxena [Thu, 1 Mar 2018 11:15:30 +0000 (06:15 -0500)]
scsi: megaraid_sas: replace is_ventura with adapter_type checks

No functional change.

Rebased for UEK kernel.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Remove redundant checks for ctrl_context
Shivasharan S [Thu, 19 Oct 2017 09:48:51 +0000 (02:48 -0700)]
scsi: megaraid_sas: Remove redundant checks for ctrl_context

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: replace instance->ctrl_context checks with instance->adapter_type
Sumit Saxena [Thu, 1 Mar 2018 13:22:34 +0000 (18:52 +0530)]
scsi: megaraid_sas: replace instance->ctrl_context checks with instance->adapter_type

Increase code readability. No functional change.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Add support for Crusader controllers
Shivasharan S [Thu, 19 Oct 2017 09:48:49 +0000 (02:48 -0700)]
scsi: megaraid_sas: Add support for Crusader controllers

Add support for PCI VID/DID 0x1000/0x0015 based MegaRAID controllers.
Since the DID 0x0015 conflicts with DELL PERC5 controllers,
add vendor ID based check specific for DELL PERC5.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: use adapter_type for all gen controllers
Shivasharan S [Thu, 19 Oct 2017 09:48:48 +0000 (02:48 -0700)]
scsi: megaraid_sas: use adapter_type for all gen controllers

No functional change.
Refactor adapter_type to set for all generation controllers, not
just for fusion controllers.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: driver version upgrade
Shivasharan S [Wed, 23 Aug 2017 11:47:08 +0000 (04:47 -0700)]
scsi: megaraid_sas: driver version upgrade

Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: call megasas_dump_frame with correct IO frame size
Shivasharan S [Wed, 23 Aug 2017 11:47:07 +0000 (04:47 -0700)]
scsi: megaraid_sas: call megasas_dump_frame with correct IO frame size

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: modified few prints in OCR and IOC INIT path
Shivasharan S [Wed, 23 Aug 2017 11:47:06 +0000 (04:47 -0700)]
scsi: megaraid_sas: modified few prints in OCR and IOC INIT path

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: replace internal FALSE/TRUE definitions with false/true
Shivasharan S [Wed, 23 Aug 2017 11:47:05 +0000 (04:47 -0700)]
scsi: megaraid_sas: replace internal FALSE/TRUE definitions with false/true

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Return pended IOCTLs with cmd_status MFI_STAT_WRONG_STATE in...
Shivasharan S [Wed, 23 Aug 2017 11:47:04 +0000 (04:47 -0700)]
scsi: megaraid_sas: Return pended IOCTLs with cmd_status MFI_STAT_WRONG_STATE in case adapter is dead

After a kill adapter, since the cmd_status is not set, the IOCTLs will
be hung in driver resulting in application hang.  Set cmd_status
MFI_STAT_WRONG_STATE when completing pended IOCTLs.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: use vmalloc for crash dump buffers and driver's local RAID map
Shivasharan S [Wed, 23 Aug 2017 11:47:03 +0000 (04:47 -0700)]
scsi: megaraid_sas: use vmalloc for crash dump buffers and driver's local RAID map

Driver's local RAID map is accessed frequently. We will first try to get
memory from __get_free_pages. If this fails, fall back to using vmalloc.
For crash dump buffers always prefer vmalloc.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Use SMID for Task abort case only
Shivasharan S [Wed, 23 Aug 2017 11:47:02 +0000 (04:47 -0700)]
scsi: megaraid_sas: Use SMID for Task abort case only

In TM code, smid_task is valid only in case of task aborts.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Check valid aen class range to avoid kernel panic
Shivasharan S [Wed, 23 Aug 2017 11:47:01 +0000 (04:47 -0700)]
scsi: megaraid_sas: Check valid aen class range to avoid kernel panic

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Fix endianness issues in DCMD handling
Shivasharan S [Wed, 23 Aug 2017 11:47:00 +0000 (04:47 -0700)]
scsi: megaraid_sas: Fix endianness issues in DCMD handling

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Do not re-fire shutdown DCMD after OCR
Shivasharan S [Wed, 23 Aug 2017 11:46:59 +0000 (04:46 -0700)]
scsi: megaraid_sas: Do not re-fire shutdown DCMD after OCR

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Call megasas_complete_cmd_dpc_fusion every 1 second while there...
Shivasharan S [Wed, 23 Aug 2017 11:46:58 +0000 (04:46 -0700)]
scsi: megaraid_sas: Call megasas_complete_cmd_dpc_fusion every 1 second while there are pending commands

megasas_wait_for_outstanding_fusion checks for pending commands every 1
second. But megasas_complete_cmd_dpc_fusion is only called every 5
seconds.  If the commands are already completed by firmware, there is an
additional delay of 5 seconds before driver will process completion for
these commands.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: Use synchronize_irq in target reset case
Shivasharan S [Wed, 23 Aug 2017 11:46:57 +0000 (04:46 -0700)]
scsi: megaraid_sas: Use synchronize_irq in target reset case

Similar to task abort case, use synchronize_irq API in target reset
case.  Also, remove redundant call to megasas_complete_cmd_dpc_fusion
after calling megasas_sync_irqs in task abort case.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: set minimum value of resetwaittime to be 1 secs
Shivasharan S [Wed, 23 Aug 2017 11:46:56 +0000 (04:46 -0700)]
scsi: megaraid_sas: set minimum value of resetwaittime to be 1 secs

Setting resetwaittime to 0 during a FW fault will result in driver not
calling the OCR.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: mismatch of allocated MFI frame size and length exposed in MFI...
Shivasharan S [Wed, 23 Aug 2017 11:46:55 +0000 (04:46 -0700)]
scsi: megaraid_sas: mismatch of allocated MFI frame size and length exposed in MFI MPT pass through command

Driver allocated 256 byte MFI frames bytes but while sending MFI frame
(embedded inside chain frame of MPT frame) to firmware, driver sets the
length as 4k. This results in DMA read error messages during boot.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: fix error handle in megasas_probe_one
weiping zhang [Mon, 7 Aug 2017 17:26:57 +0000 (01:26 +0800)]
scsi: megaraid_sas: fix error handle in megasas_probe_one

megasas_mgmt_info.max_index has increased by 1 before megasas_io_attach,
if megasas_io_attach return error, then goto fail_io_attach,
megasas_mgmt_info.instance has a wrong index here. So first reduce
max_index and then set that instance to NULL.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: fix allocate instance->pd_info twice
weiping [Tue, 8 Aug 2017 05:15:55 +0000 (13:15 +0800)]
scsi: megaraid_sas: fix allocate instance->pd_info twice

fix allocate instance->pd_info twice which was introduced by 96188a89cc6d.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: remove DRIVER_ATTR() usage
Greg Kroah-Hartman [Wed, 19 Jul 2017 12:50:06 +0000 (14:50 +0200)]
scsi: remove DRIVER_ATTR() usage

It's better to use the DRIVER_ATTR_RW() and DRIVER_ATTR_RO() macros to
explicitly show that this is a read/write or read/only sysfs file.  So
convert the remaining SCSI drivers that use the old style to use the
newer macros.

Bonus is that this removes some checkpatch.pl warnings :)

This is part of a series to drop DRIVER_ATTR() from the tree entirely.

Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: Willem Riede <osst@riede.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid: Replace PCI pool old API
Romain Perier [Thu, 6 Jul 2017 08:13:06 +0000 (10:13 +0200)]
scsi: megaraid: Replace PCI pool old API

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

Signed-off-by: Romain Perier <romain.perier@collabora.com>
Reviewed-by: Peter Senna Tschudin <peter.senna@collabora.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid_sas: fix memleak in megasas_alloc_cmdlist_fusion
Shu Wang [Fri, 21 Jul 2017 10:54:09 +0000 (18:54 +0800)]
scsi: megaraid_sas: fix memleak in megasas_alloc_cmdlist_fusion

Found this issue by kmemleak, a few kb mem was leaked in
megasas_alloc_cmdlist_fusion when kzalloc failed for one
megasas_cmd_fusion allocation.

unreferenced object 0xffff88045dbd2000 (size 8192):
  comm "systemd-udevd", pid 323, jiffies 4294671759 (age 49.008s)
  backtrace:
    [<ffffffff8176166a>] kmemleak_alloc+0x4a/0xa0
    [<ffffffff812186a8>] __kmalloc+0xe8/0x220
    [<ffffffffc0060594>] megasas_alloc_cmdlist_fusion+0x34/0xe0 [megaraid_sas]
(gdb) list *megasas_alloc_cmdlist_fusion+0x34
0xd5c4 is in megasas_alloc_cmdlist_fusion
               (drivers/scsi/megaraid/megaraid_sas_fusion.c:443).
    [<ffffffffc0060ca5>] megasas_alloc_cmds_fusion+0x25/0x410 [megaraid_sas]
    [<ffffffffc0061edf>] megasas_init_adapter_fusion+0x21f/0x640 [megaraid_sas]
    [<ffffffffc005df17>] megasas_init_fw+0x357/0xd30 [megaraid_sas]
    [<ffffffffc005ef26>] megasas_probe_one.part.33+0x636/0x1100 [megaraid_sas]
    [<ffffffffc005fa36>] megasas_probe_one+0x46/0xc0 [megaraid_sas]
    [<ffffffff813d2ca5>] local_pci_probe+0x45/0xa0
    [<ffffffff813d4222>] pci_device_probe+0x192/0x1b0
    [<ffffffff814e3658>] driver_probe_device+0x2a8/0x460
    [<ffffffff814e38ed>] __driver_attach+0xdd/0xe0
    [<ffffffff814e124c>] bus_for_each_dev+0x6c/0xc0
    [<ffffffff814e2dde>] driver_attach+0x1e/0x20
    [<ffffffff814e2775>] bus_add_driver+0x45/0x270
    [<ffffffff814e4400>] driver_register+0x60/0xe0
unreferenced object 0xffff880454ce3600 (size 192):
  backtrace:
    [<ffffffff8176166a>] kmemleak_alloc+0x4a/0xa0
    [<ffffffff8121801a>] kmem_cache_alloc_trace+0xca/0x1d0
    [<ffffffffc00605d7>] megasas_alloc_cmdlist_fusion+0x77/0xe0 [megaraid_sas]
(gdb) list *megasas_alloc_cmdlist_fusion+0x77
0xd607 is in megasas_alloc_cmdlist_fusion
                (drivers/scsi/megaraid/megaraid_sas_fusion.c:450).
    [<ffffffffc0060ca5>] megasas_alloc_cmds_fusion+0x25/0x410 [megaraid_sas]
    [<ffffffffc0061edf>] megasas_init_adapter_fusion+0x21f/0x640 [megaraid_sas]
    [<ffffffffc005df17>] megasas_init_fw+0x357/0xd30 [megaraid_sas]
    [<ffffffffc005ef26>] megasas_probe_one.part.33+0x636/0x1100 [megaraid_sas]
    [<ffffffffc005fa36>] megasas_probe_one+0x46/0xc0 [megaraid_sas]
    [<ffffffff813d2ca5>] local_pci_probe+0x45/0xa0
    [<ffffffff813d4222>] pci_device_probe+0x192/0x1b0
    [<ffffffff814e3658>] driver_probe_device+0x2a8/0x460
    [<ffffffff814e38ed>] __driver_attach+0xdd/0xe0
    [<ffffffff814e124c>] bus_for_each_dev+0x6c/0xc0
    [<ffffffff814e2dde>] driver_attach+0x1e/0x20
    [<ffffffff814e2775>] bus_add_driver+0x45/0x270
    [<ffffffff814e4400>] driver_register+0x60/0xe0

Signed-off-by: Shu Wang <shuwang@redhat.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: megaraid: Fix a sleep-in-atomic bug
Jia-Ju Bai [Wed, 31 May 2017 02:56:56 +0000 (10:56 +0800)]
scsi: megaraid: Fix a sleep-in-atomic bug

The driver may sleep under a spin lock, and the function call path is:
mraid_mm_attach_buf (acquire the lock by spin_lock_irqsave)
  pci_pool_alloc(GFP_KERNEL) --> may sleep

To fix it, the "GFP_KERNEL" is replaced with "GFP_ATOMIC".

[mkp: fixed whitespace]

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agodrivers/scsi/megaraid: remove expensive inline from megasas_return_cmd
Andi Kleen [Mon, 8 May 2017 22:58:53 +0000 (15:58 -0700)]
drivers/scsi/megaraid: remove expensive inline from megasas_return_cmd

Remove an inline from a fairly big function that is used often.  It's
unlikely that calling or not calling it makes a lot of difference.

Saves around 8k text in my kernel.

     text    data     bss     dec     hex filename
  9047801 5367568 11116544        25531913        1859609 vmlinux-before-megasas
  9039417 5367568 11116544        25523529        1857549 vmlinux-megasas

Link: http://lkml.kernel.org/r/20170315021431.13107-7-andi@firstfloor.org
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Kashyap Desai <kashyap.desai@avagotech.com>
Cc: Sumit Saxena <sumit.saxena@avagotech.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agomegaraid_sas: remove redundant code initialzing *pDevHandle with MR_DEVHANDLE_INVALID
Sumit Saxena [Thu, 1 Mar 2018 12:57:52 +0000 (18:27 +0530)]
megaraid_sas: remove redundant code initialzing *pDevHandle with MR_DEVHANDLE_INVALID

Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Orabug: 27625001
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agousb: usbtest: fix NULL pointer dereference
Alan Stern [Fri, 29 Sep 2017 14:54:24 +0000 (10:54 -0400)]
usb: usbtest: fix NULL pointer dereference

If the usbtest driver encounters a device with an IN bulk endpoint but
no OUT bulk endpoint, it will try to dereference a NULL pointer
(out->desc.bEndpointAddress).  The problem can be solved by adding a
missing test.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
(cherry picked from commit 7c80f9e4a588f1925b07134bb2e3689335f6c6d8)

Orabug: 27602322
CVE: CVE-2017-16532
Signed-off-by: Tim Tianyang Chen <tianyang.chen@oracle.com>
Reviewed-by: Ashok Vairavan <ashok.vairavan@oracle.com>
7 years agords: Incorrect reference counting in TCP socket creation
Ka-Cheong Poon [Tue, 27 Feb 2018 03:05:47 +0000 (19:05 -0800)]
rds: Incorrect reference counting in TCP socket creation

Commit a670499f5a9a ("rds: tcp: use sock_create_lite() to create the
accept socket") has a reference counting issue in TCP socket creation
when accepting a new connection.  The code uses sock_create_lite() to
create a kernel socket.  But it does not do __module_get() on the
socket owner.  When the connection is shutdown and sock_release() is
called to free the socket, the owner's reference count is decremented
and becomes incorrect.  Note that this bug only shows up when IPv6 is
configured as a kernel module.

Orabug: 27602824

Signed-off-by: Ka-Cheong Poon <ka-cheong.poon@oracle.com>
Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
7 years agoenic: enable rq before updating rq descriptors
Govindarajulu Varadarajan [Wed, 28 Feb 2018 17:50:56 +0000 (09:50 -0800)]
enic: enable rq before updating rq descriptors

rq should be enabled before posting the buffers to rq desc. If not hw sees
stale value and casuses DMAR errors.

Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Orabug: 27587345
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoenic: add sw timestamp support
Govindarajulu Varadarajan [Fri, 1 Dec 2017 18:21:40 +0000 (10:21 -0800)]
enic: add sw timestamp support

Add ethtool ops to advertise sw timestamping.
Call skb_tx_timestamp() just before ringing the wq doorbell.

Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit fb7516d42478ebc8e2f00efb76ef96f7b68fd8d3)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoenic: add wq clean up budget
Govindarajulu Varadarajan [Thu, 21 Dec 2017 16:12:28 +0000 (08:12 -0800)]
enic: add wq clean up budget

In case of tx clean up, we set '-1' as budget. This means clean up until
wq is empty or till (1 << 32) pkts are cleaned. Under heavy load this
will run for long time and cause
"watchdog: BUG: soft lockup - CPU#25 stuck for 21s!" warning.

This patch sets wq clean up budget to 256.

Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit 18feb87105c3c16dc01e6981a6aafb175679b997)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoenic: Add support for 'ethtool -g/-G'
Parvi Kaustubhi [Wed, 1 Nov 2017 15:44:47 +0000 (08:44 -0700)]
enic: Add support for 'ethtool -g/-G'

Add support for displaying and modifying rx and tx ring sizes using
ethtool.

Also, increasing version to  2.3.0.45

Signed-off-by: Parvi Kaustubhi <pkaustub@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit ed519b7488a42ce549ef7eae8dd13e043dde10a4)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoenic: reset fetch index
Parvi Kaustubhi [Wed, 1 Nov 2017 15:44:46 +0000 (08:44 -0700)]
enic: reset fetch index

Since we are allowing rx ring size modification, reset fetch index
everytime. Otherwise it could have a stale value that can lead to a null
pointer dereference.

Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Signed-off-by: Parvi Kaustubhi <pkaustub@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit e6cdfcc581866625980a89391be4e6a8b379d0c5)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agodrivers: net: enic: use setup_timer() helper.
Allen Pais [Thu, 21 Sep 2017 17:05:22 +0000 (22:35 +0530)]
drivers: net: enic: use setup_timer() helper.

Use setup_timer function instead of initializing timer with the
    function and data fields.

Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit 570ba3e82befbba7649e459fedc4aab27510ef44)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agodrivers: net: enic: use setup_timer() helper.
Allen Pais [Thu, 21 Sep 2017 17:04:45 +0000 (22:34 +0530)]
drivers: net: enic: use setup_timer() helper.

Use setup_timer function instead of initializing timer with the
    function and data fields.

Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit 7afd516ff75e967873d7bdcb8f9b1180c2400b57)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoenic: update enic maintainers
Govindarajulu Varadarajan [Tue, 21 Mar 2017 22:07:48 +0000 (15:07 -0700)]
enic: update enic maintainers

update enic maintainers

Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit dd1ef79120e1600cb48320cf80a612ee6510110c)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agocisco: enic: Fic an error handling path in 'vnic_dev_init_devcmd2()'
Christophe Jaillet [Sat, 8 Jul 2017 04:51:35 +0000 (06:51 +0200)]
cisco: enic: Fic an error handling path in 'vnic_dev_init_devcmd2()'

if 'ioread32()' returns 0xFFFFFFF, we have to go through the error
handling path as done everywhere else in this function.

Move the 'err_free_wq' label to better match its name and its location
and add a new label 'err_disable_wq'.
Update the code accordingly.

Fixes: 373fb0873d43 ("enic: add devcmd2")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit fdf99b3ffcdd8471ee3104512198a178b7351a02)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoenic: Fix format truncation warning
Govindarajulu Varadarajan [Mon, 19 Jun 2017 23:28:44 +0000 (16:28 -0700)]
enic: Fix format truncation warning

With -Wformat-truncation, gcc throws the following warning.

Fix this by increasing the size of devname to accommodate 15 character
netdev interface name and description.

Remove length format precision for %s. We can fit entire name.

Also increment the version.

drivers/net/ethernet/cisco/enic/enic_main.c: In function ‘enic_open’:
drivers/net/ethernet/cisco/enic/enic_main.c:1740:15: warning: ‘%u’ directive output may be truncated writing between 1 and 2 bytes into a region of size between 1 and 12 [-Wformat-truncation=]
     "%.11s-rx-%u", netdev->name, i);
               ^~
drivers/net/ethernet/cisco/enic/enic_main.c:1740:5: note: directive argument in the range [0, 16]
     "%.11s-rx-%u", netdev->name, i);
     ^~~~~~~~~~~~~
drivers/net/ethernet/cisco/enic/enic_main.c:1738:4: note: ‘snprintf’ output between 6 and 18 bytes into a destination of size 16
    snprintf(enic->msix[intr].devname,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     sizeof(enic->msix[intr].devname),
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     "%.11s-rx-%u", netdev->name, i);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit 7044f429e70d987cdc780f26a9b9951970645966)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoenic: add devcmds for vxlan offload
Govindarajulu Varadarajan [Thu, 9 Feb 2017 00:43:07 +0000 (16:43 -0800)]
enic: add devcmds for vxlan offload

This patch adds devcmds needed for vxlan offload. Implement 3 new devcmd

overlay_offload_ctrl: enable/disable offload
overlay_offload_cfg: update offload udp port number
get_supported_feature_ver: get hw supported offload version. Each
   version has different bitmap for csum_ok/encap

Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit ca0291798227a6da0f3ba6c2e3a43d94d5dcf591)

Orabug: 27587345
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoenic: increment devcmd2 result ring in case of timeout
Sandeep Pillai [Wed, 3 Feb 2016 09:10:44 +0000 (14:40 +0530)]
enic: increment devcmd2 result ring in case of timeout

Firmware posts the devcmd result in result ring. In case of timeout, driver
does not increment the current result pointer and firmware could post the
result after timeout has occurred. During next devcmd, driver would be
reading the result of previous devcmd.

Fix this by incrementing result even in case of timeout.

Fixes: 373fb0873d43 ("enic: add devcmd2")
Signed-off-by: Sandeep Pillai <sanpilla@cisco.com>
Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27587345
(cherry picked from commit ca7f41a4957b872577807169bd7464b36aae9b9c)
Conflict in enic.h - avoid reverting version number
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
7 years agoscsi: fnic: use kzalloc in fnic_fcoe_process_vlan_resp
Rasmus Villemoes [Mon, 8 Jan 2018 23:11:15 +0000 (00:11 +0100)]
scsi: fnic: use kzalloc in fnic_fcoe_process_vlan_resp

This saves a little .text and gets rid of the unmotivated line break and
the sizeof(...) style inconsistency.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit dbc1ebe7b0fd43f7d74ba0e87b411eb48c9fdeb2)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: add a space after %p in printf format
Nicolas Iooss [Sun, 10 Dec 2017 19:23:11 +0000 (20:23 +0100)]
scsi: fnic: add a space after %p in printf format

fnic_fcpio_icmnd_cmpl_handler() displays the value of sc with:

    FNIC_SCSI_DBG(KERN_INFO...
        "... sc = 0x%p"
        "scsi_status ..."
        ...

As the literal strings get merged, the function uses %ps instead of the
intended raw %p format. Fix this by inserting a space.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit f280c77dc9bb850bc49a126ef5a088e7340a61b6)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: Fix coccinelle warnings
Vasyl Gomonovych [Tue, 21 Nov 2017 21:15:46 +0000 (22:15 +0100)]
scsi: fnic: Fix coccinelle warnings

Remove the duplicate copies of this simple function and use an
open-coded version.

drivers/scsi/fnic/fnic_debugfs.c:122:11-31: WARNING opportunity for simple_open, see also structure on line 223

Generated by: coccinelle/api/simple_open.cocci

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit d9462140f7ab0400206041d2732c740dea2d1ff9)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: do not call host reset from command abort
Hannes Reinecke [Fri, 25 Aug 2017 11:57:00 +0000 (13:57 +0200)]
scsi: fnic: do not call host reset from command abort

Command abort already returns FAILED, which will then be escalated to a
host reset. So no need to call host_reset directly.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 7c3a50bb9b6ec289126085ccfe205ed0cc3c0a85)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: fix format string overflow warning
Arnd Bergmann [Fri, 14 Jul 2017 12:06:58 +0000 (14:06 +0200)]
scsi: fnic: fix format string overflow warning

The MSI interrupt name can require 11 bytes in addition to the device name,
for a total of 23 bytes:

drivers/scsi/fnic/fnic_isr.c: In function 'fnic_request_intr':
drivers/scsi/fnic/fnic_isr.c:192:4: error: '-fcs-rq' directive writing 7 bytes into a region of size between 5 and 16 [-Werror=format-overflow=]
    "%.11s-fcs-rq", fnic->name);
drivers/scsi/fnic/fnic_isr.c:206:3: note: 'sprintf' output between 12 and 23 bytes into a destination of size 16
   sprintf(fnic->msix[FNIC_MSIX_ERR_NOTIFY].devname,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "%.11s-err-notify", fnic->name);

This extends the buffer to fit any possible value.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 514e59c1195f2634dab025d952242f5e69e052c7)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: correct speed display and add support for 25,40 and 100G
Satish Kharat [Tue, 27 Jun 2017 00:48:44 +0000 (17:48 -0700)]
scsi: fnic: correct speed display and add support for 25,40 and 100G

Setting speed based on the vinc device parameter read during
linkup. Also adding support to display 25,40 and 100G

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Sesidhar Baddela <sebaddel@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit c22fa50b2d41f3091d2ab0acf60ffdedb7ccd765)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: added timestamp reporting in fnic debug stats
Satish Kharat [Tue, 27 Jun 2017 00:48:08 +0000 (17:48 -0700)]
scsi: fnic: added timestamp reporting in fnic debug stats

Added the timestamps for
1. current timestamp
2. last fnic stats read timestamp
3. last fnic stats reset timestamp
and the deltas since last stats read and last reset in fnic stats.
fnic stats uses debugfs

Signed-off-by: Sesidhar Baddela <sebaddel@cisco.com>
Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 43caa03fec79d062c5f7a959a823770d72717b24)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: Zero io_cmpl_skip on fw reset completion
Satish Kharat [Tue, 27 Jun 2017 00:46:23 +0000 (17:46 -0700)]
scsi: fnic: Zero io_cmpl_skip on fw reset completion

io_cmpl_skip keep track of number of completions to skip when stats are
reset. If a fw_reset happens immediately after stats reset it could put
it out of sync so need to reset io_cmpl_skip when fw reset is completed.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Sesidhar Baddela <sebaddel@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 1cdf8bc18f1ee43a39e543506fff8d5db3020ae1)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: Ratelimit printks to avoid flooding when vlan is not set by the switch.i
Satish Kharat [Wed, 1 Mar 2017 00:11:57 +0000 (16:11 -0800)]
scsi: fnic: Ratelimit printks to avoid flooding when vlan is not set by the switch.i

This is to avoid the log from being filled with vlan discovery messages
when there is no vlan configured on the switch.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Sesidhar Baddela <sebaddel@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit b43abcbbd5b10d5f057c8388cc4eff9ff1fe2fd6)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: fnic: use kernel's '%pM' format option to print MAC
Andy Shevchenko [Sat, 22 Oct 2016 17:32:26 +0000 (20:32 +0300)]
scsi: fnic: use kernel's '%pM' format option to print MAC

Instead of supplying each byte through stack let's use %pM specifier.

Cc: Hiral Patel <hiralpat@cisco.com>
Cc: Suma Ramars <sramars@cisco.com>
Acked-by: Tom Tucker <tom@opengridcomputing.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 36fe90b0f0bdc9d030e88ba2153f3c8d6b6a5964)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agofnic: pci_dma_mapping_error() doesn't return an error code
Dan Carpenter [Thu, 7 Jul 2016 08:23:59 +0000 (11:23 +0300)]
fnic: pci_dma_mapping_error() doesn't return an error code

pci_dma_mapping_error() returns true on error and false on success.

Fixes: fd6ddfa4c1dd ('fnic: check pci_map_single() return value')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit dd7328e4c53649c1c7ec36bc1cf5b229b8662047)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agofnic: move printk()s outside of the critical code section.
Maurizio Lombardi [Wed, 16 Mar 2016 13:44:08 +0000 (14:44 +0100)]
fnic: move printk()s outside of the critical code section.

This patch moves a printk() outside of the code section where interrupt
are disabled. In some cases a flood of error messages may cause a kernel
panic.  It also removes one of the printk()s because the same error
message was printed twice.

[709686.317197] Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 12
[709686.317200] CPU: 12 PID: 1963 Comm: systemd-journal Tainted: GF          O--------------   3.10.0-229.el7.x86_64 #1
[709686.317201] Hardware name: Cisco Systems Inc UCSB-B200-M3/UCSB-B200-M3, BIOS B200M3.2.2.3.6.030620151309 03/06/2015
[709686.317206]  ffffffff8182b2e8 00000000392722ba ffff88046fcc5c48 ffffffff81603f36
[709686.317209]  ffff88046fcc5cc8 ffffffff815fd7da 0000000000000010 ffff88046fcc5cd8
[709686.317211]  ffff88046fcc5c78 00000000392722ba ffff88046fcc5c88 000000000000000c
[709686.317212] Call Trace:
[709686.317221]  <NMI>  [<ffffffff81603f36>] dump_stack+0x19/0x1b
[709686.317223]  [<ffffffff815fd7da>] panic+0xd8/0x1e7
[709686.317227]  [<ffffffff8110a760>] ? watchdog_enable_all_cpus.part.2+0x40/0x40
[709686.317229]  [<ffffffff8110a822>] watchdog_overflow_callback+0xc2/0xd0
[709686.317233]  [<ffffffff8114c901>] __perf_event_overflow+0xa1/0x250
[709686.317235]  [<ffffffff8114d404>] perf_event_overflow+0x14/0x20
[709686.317239]  [<ffffffff810301fd>] intel_pmu_handle_irq+0x1fd/0x410
[709686.317242]  [<ffffffff811908d1>] ? unmap_kernel_range_noflush+0x11/0x20
[709686.317246]  [<ffffffff81373574>] ? ghes_copy_tofrom_phys+0x124/0x210
[709686.317249]  [<ffffffff8160cfcb>] perf_event_nmi_handler+0x2b/0x50
[709686.317251]  [<ffffffff8160c719>] nmi_handle.isra.0+0x69/0xb0
[709686.317252]  [<ffffffff8160c830>] do_nmi+0xd0/0x340
[709686.317256]  [<ffffffff8160bb71>] end_repeat_nmi+0x1e/0x2e
[709686.317260]  [<ffffffff812e24fd>] ? memcpy+0xd/0x110
[709686.317263]  [<ffffffff812e24fd>] ? memcpy+0xd/0x110
[709686.317265]  [<ffffffff812e24fd>] ? memcpy+0xd/0x110
[709686.317269]  <<EOE>>  [<ffffffff8132c297>] ? vgacon_scroll+0x2d7/0x330
[709686.317273]  [<ffffffff813a086c>] scrup+0xfc/0x110
[709686.317275]  [<ffffffff813a0920>] lf+0xa0/0xb0
[709686.317278]  [<ffffffff813a1b32>] vt_console_print+0x2d2/0x420
[709686.317283]  [<ffffffff8106f4a1>] call_console_drivers.constprop.15+0x91/0xf0
[709686.317287]  [<ffffffff8107069f>] console_unlock+0x3bf/0x400
[709686.317291]  [<ffffffff81070996>] vprintk_emit+0x2b6/0x530
[709686.317294]  [<ffffffff815fd961>] printk_emit+0x44/0x5b
[709686.317297]  [<ffffffff81070d98>] devkmsg_writev+0x158/0x1d0
[709686.317303]  [<ffffffff811c5ef9>] do_sync_readv_writev+0x79/0xd0
[709686.317307]  [<ffffffff811c73ee>] do_readv_writev+0xce/0x260
[709686.317310]  [<ffffffff811c8d18>] ? __sb_start_write+0x58/0x110
[709686.317314]  [<ffffffff811c7615>] vfs_writev+0x35/0x60
[709686.317318]  [<ffffffff811c776c>] SyS_writev+0x5c/0xd0
[709686.317322]  [<ffffffff81613da9>] system_call_fastpath+0x16/0x1b

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 14cee5b4de4b9e01438d58d1806e7eef78720405)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agofnic: check pci_map_single() return value
Maurizio Lombardi [Wed, 12 Aug 2015 15:00:23 +0000 (17:00 +0200)]
fnic: check pci_map_single() return value

the kernel prints some warnings when compiled with CONFIG_DMA_API_DEBUG.
This is because the fnic driver doesn't check the return value of
pci_map_single().

[   11.942770] scsi host12: fnic
[   11.950811] ------------[ cut here ]------------
[   11.950818] WARNING: at lib/dma-debug.c:937 check_unmap+0x47b/0x920()
[   11.950821] fnic 0000:0c:00.0: DMA-API: device driver failed to check map error[device address=0x0000002020a30040] [size=44 bytes] [mapped as single]

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed By: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
(cherry picked from commit fd6ddfa4c1ddfb4a149b31845144b4cf3cbef54d)

Orabug: 27587343
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoretpoline: move setting of sysctl_ibrs_enabled and sysctl_ibpb_enabled to where SPEC_...
Chuck Anderson [Mon, 26 Feb 2018 10:04:33 +0000 (02:04 -0800)]
retpoline: move setting of sysctl_ibrs_enabled and sysctl_ibpb_enabled to where SPEC_CTRL_IBRS_INUSE and SPEC_CTRL_IBPB_INUSE are set

Move the setting of sysctl_ibrs_enabled and sysctl_ibpb_enabled to the
functions that set SPEC_CTRL_IBRS_INUSE and SPEC_CTRL_IBPB_INUSE.

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Conflicts:
arch/x86/include/asm/spec_ctrl.h

7 years agoretpoline: set IBRS and IBPB in use only on the boot CPU call to init_scattered_cpuid...
Chuck Anderson [Mon, 26 Feb 2018 09:40:58 +0000 (01:40 -0800)]
retpoline: set IBRS and IBPB in use only on the boot CPU call to init_scattered_cpuid_features()

Setting IBRS and IBPB in use is a system wide issue, not a per-CPU
issue.  Set them only on the boot CPU's call to
init_scattered_cpuid_features().

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Conflicts:
arch/x86/kernel/cpu/scattered.c
(merged with be596ab27 ("x86/speculation: Use IBRS if available before
 calling into firmware"))

7 years agoretpoline: display IBPB feature status along with IBRS status
Chuck Anderson [Mon, 26 Feb 2018 09:27:37 +0000 (01:27 -0800)]
retpoline: display IBPB feature status along with IBRS status

retpoline_enabled() lists if the IBRS mitigation is in use and if the
kernel was compiled with retpoline.  Add whether IBPB is in use to the
list.

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agoretpoline: move lock/unlock of spec_ctrl_mutex to check_modinfo()
Chuck Anderson [Mon, 26 Feb 2018 08:59:51 +0000 (00:59 -0800)]
retpoline: move lock/unlock of spec_ctrl_mutex to check_modinfo()

Testing has found that check_modinfo() will call disable_retpoline()
concurrently for the same module.  Serialization through
spec_ctrl_mutex in disable_retpoline() keeps the retpoline state sane
but misleading messages are issued during the duplicate call.
Move the lock/unlock of spec_ctrl_mutex to check_modinfo() so that the
first call to disable_retpoline() will disable retpoline before the
duplicate call checks to see if retpoline is disabled.

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agoretpoline: call clear_retpoline_fallback() with boot parm spectre_v2_heuristics=off
Chuck Anderson [Mon, 26 Feb 2018 08:33:53 +0000 (00:33 -0800)]
retpoline: call clear_retpoline_fallback() with boot parm spectre_v2_heuristics=off

retpoline_fallback=off is one of the spectre_v2_heuristics boot parm
settings.  Disable retpoline fallback when boot parameter
spectre_v2_heuristics=off is specified.

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agoretpoline: add brackets to check_ibrs_inuse() and clear_ibpb_inuse()
Chuck Anderson [Mon, 26 Feb 2018 08:20:30 +0000 (00:20 -0800)]
retpoline: add brackets to check_ibrs_inuse() and clear_ibpb_inuse()

Add brackets to the "else" clause in both check_ibrs_inuse() and
clear_ibpb_inuse() to match indentations.  The brackets are not
required but may prevent a bug when indented code is mistakenly added
without adding brackets.

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agoretpoline/module: do not enable IBRS/IPBP if SPEC_CTRL_IBRS_ADMIN_DISABLED/SPEC_CTRL_...
Chuck Anderson [Thu, 22 Feb 2018 22:01:24 +0000 (14:01 -0800)]
retpoline/module: do not enable IBRS/IPBP if SPEC_CTRL_IBRS_ADMIN_DISABLED/SPEC_CTRL_IBPB_ADMIN_DISABLED is set

The retpoline fallback code in disable_retpoline() attempts to enable
the Spectre IBRS and IPBP mitigations by calling set_ibrs_inuse() and
set_ibpb_inuse().  SPEC_CTRL_IBRS_INUSE should not be set unless
SPEC_CTRL_IBRS_SUPPORTED is set and SPEC_CTRL_IBRS_ADMIN_DISABLED is not
set.  Otherwise, the kernel boot parameter noibrs, which sets
SPEC_CTRL_IBRS_ADMIN_DISABLED, is ignored and IBRS is incorrectly
enabled during retpoline fallback.

Same for set_ibpb_inuse(): it should respect
SPEC_CTRL_IBPB_ADMIN_DISABLED.

Orabug: 27625353
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agoretpoline: microcode incorrectly reported as broken during early boot
Chuck Anderson [Thu, 22 Feb 2018 22:01:24 +0000 (14:01 -0800)]
retpoline: microcode incorrectly reported as broken during early boot

init_scattered_cpuid_features() is called on each CPU to set its
capabilities based on features enumerated by the cpuid instruction.
If the CPU supports IBRS or STIBP, a call is made through
bad_spectre_microcode() to detect a microcode level that makes it
unsafe to use IBRS as a mitigation for Spectre.  A warning is issued
if the microcode is unsafe:

    Intel Spectre v2 broken microcode detected; disabling SPEC_CTRL/IBR

init_scattered_cpuid_features() may be called early during boot on the
boot CPU.  The microcode level from BIOS may be broken, triggering the
message above.  A subsequent microcode update made during early boot
could install a level that is IBRS/STIBP/IPBP safe making the warning
message misleading.  This patch skips the microcode check during early
boot.  The check is made during a subsequent call to
init_scattered_cpuid_features() after a potential microcode update.

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agoretpoline: move lock/unlock of spec_ctrl_mutex into init_scattered_cpuid_features()
Chuck Anderson [Mon, 26 Feb 2018 07:58:47 +0000 (23:58 -0800)]
retpoline: move lock/unlock of spec_ctrl_mutex into init_scattered_cpuid_features()

init_scattered_cpuid_features() changes spectre mitigation state.
Not all callers obtained spec_ctrl_mutex.  Move the lock/unlock of
spec_ctrl_mutex to init_scattered_cpuid_features() rather than have
the callers obtain it.  That also allows init_scattered_cpuid_features()
to serialize just the spectre state changes instead of the entire
function.

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agoretpoline/module: fall back to another spectre mitigation when disabling retpoline
Chuck Anderson [Mon, 12 Feb 2018 07:49:30 +0000 (23:49 -0800)]
retpoline/module: fall back to another spectre mitigation when disabling retpoline

Commit ("retpoline/module: Taint kernel for missing retpoline in module")
calls the new function disable_retpoline() when check_modinfo() determines
that a LKM being loaded was not compiled with retpoline.

This commit adds code to disable_retpoline() that attempts to fall back to
the Spectre v2 mitigations IBRS/IBPB when disabling retpoline.

Pseudocode for disable_retpoline():

if retpoline is not enabled
No messages/changes
return

if we are allowed to fall back to another mitigation
if IBRS is not in use
if we enabled it
spectre_v2_enabled = SPECTRE_V2_IBRS
pr_err("Spectre v2 mitigation set to IBRS.\n")
if we enabled IBPB mitigation
pr_err("Spectre v2 mitigation IBPB enabled.\n")
else
pr_err("Could not enable IBRS.\n")
spectre_v2_enabled = SPECTRE_V2_NONE
pr_err("No Spectre v2 mitigation to fall back to.\n")
else
spectre_v2_enabled = SPECTRE_V2_IBRS;
pr_err("Spectre v2 mitigation IBRS is set.\n")
else
spectre_v2_enabled = SPECTRE_V2_NONE;
pr_err("Cannot choose another Spectre v2 mitigation because retpoline_fallback is off.\n")

if spectre_v2_enabled == SPECTRE_V2_NONE
pr_err("system may be vulnerable to spectre\n")

The attempt to fall back can be disabled with the new kernel boot parameter
spectre_v2_heuristics=[retpoline_fallback=off]
Disabling retpoline fallback can also be done through debugfs
"retpoline_fallback".

Orabug: 27457549

Suggested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Todd Vierling <todd.vierling@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
Documentation/kernel-parameters.txt
arch/x86/include/asm/spec_ctrl.h
arch/x86/kernel/cpu/spec_ctrl.c

7 years agoretpoline/module: add bit defs for use_ibpb
Chuck Anderson [Mon, 12 Feb 2018 06:27:25 +0000 (22:27 -0800)]
retpoline/module: add bit defs for use_ibpb

Replace bit references for IBPB state in use_ibpb with:

    SPEC_CTRL_IBPB_INUSE
    SPEC_CTRL_IBPB_SUPPORTED
    SPEC_CTRL_IBPB_ADMIN_DISABLED

Change comment block describing use_ibrs flags to use symbolic values.
Remove duplicate comment block describing flag values in use_ibrs and use_ibpb.
Cosmetic change to defs for sysctl_ibrs_enabled, sysctl_ibpb_enabled and
sysctl_lfence_enabled in preparation for adding additional sysctl_* values.

Orabug: 27457549

Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
arch/x86/kernel/cpu/spec_ctrl.c

7 years agox86/spectre_v2: Fix the documentation to say the right thing.
Konrad Rzeszutek Wilk [Mon, 26 Feb 2018 21:36:08 +0000 (16:36 -0500)]
x86/spectre_v2: Fix the documentation to say the right thing.

That is if you disable the heuristics then it will just
use retpoline all the time instead of enabling IBRS for
Skylake+.

OraBug: 27601710
Reviewed-by: Allen Pais <allen.pais@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7 years agox86/spectre_v2: Don't check bad microcode versions when running under hypervisors.
Konrad Rzeszutek Wilk [Mon, 26 Feb 2018 14:35:01 +0000 (09:35 -0500)]
x86/spectre_v2: Don't check bad microcode versions when running under hypervisors.

As:
 1) We know they lie about the env anyhow (host mismatch)
 2) Even if the hypervisor (Xen, KVM, VMWare, etc) provided
    a valid "correct" value, it all gets to be very murky
    when migration happens (do you provide the "new"
    microcode of the machine?).

And in reality the cloud vendors are the ones that should make
sure that the microcode that is running is correct and we should
just sing lalalala and believe them.

Orabug: 27601736
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Allen Pais <allen.pais@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7 years agox86/speculation: Use IBRS if available before calling into firmware
David Woodhouse [Tue, 27 Feb 2018 07:54:04 +0000 (02:54 -0500)]
x86/speculation: Use IBRS if available before calling into firmware

Retpoline means the kernel is safe because it has no indirect branches.
But firmware isn't, so use IBRS for firmware calls if it's available.

Block preemption while IBRS is set, although in practice the call sites
already had to be doing that.

Ignore hpwdt.c for now. It's taking spinlocks and calling into firmware
code, from an NMI handler. I don't want to touch that with a bargepole.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: arjan.van.de.ven@intel.com
Cc: bp@alien8.de
Cc: dave.hansen@intel.com
Cc: jmattson@google.com
Cc: karahmed@amazon.de
Cc: kvm@vger.kernel.org
Cc: pbonzini@redhat.com
Cc: rkrcmar@redhat.com
Link: http://lkml.kernel.org/r/1519037457-7643-2-git-send-email-dwmw@amazon.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry-pick from dd84441a7971)
[Backport:

We need to be more dynamic. We may have retpoline disabled for some time and
then when somebody loads an proprietary module (say nvidia.ko) we can stop making
these calls (as we would be doing IBRS calls now).

As such we we use a new bit on the ibrs global value - which on bootup is set
to be enabled  (if IBRS firmware is detected), and then if retpoline is selected
it is still used. But if 'spectre_v2=off' is off, then it is disabled.

The original feature uses a CPU feature, but we are much more dynamic
thanks to the SysFS and retpoline-module-check.]

Orabug: 27516477
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7 years agoRevert "x86/spec_ctrl: Add 'nolfence' knob to disable fallback for spectre_v2 mitigation"
Konrad Rzeszutek Wilk [Tue, 27 Feb 2018 01:07:51 +0000 (20:07 -0500)]
Revert "x86/spec_ctrl: Add 'nolfence' knob to disable fallback for spectre_v2 mitigation"

This reverts commit f51532c93e3359743f0f8e226f1503123d3b1ae5.

And also other pieces of code that would use this.

Orabug: 27601789
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7 years agoRevert "x86/spec: Add 'lfence_enabled' in sysfs"
Konrad Rzeszutek Wilk [Tue, 27 Feb 2018 01:13:00 +0000 (20:13 -0500)]
Revert "x86/spec: Add 'lfence_enabled' in sysfs"

This reverts commit d4ac621c1079ddd1b390ab2f56eedbda4aa8d1d7.

OraBug: 27601789
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7 years agoKVM: Disable irq while unregistering user notifier
Ignacio Alvarado [Wed, 28 Feb 2018 11:09:31 +0000 (11:09 +0000)]
KVM: Disable irq while unregistering user notifier

Function user_notifier_unregister should be called only once for each
registered user notifier.

Function kvm_arch_hardware_disable can be executed from an IPI context
which could cause a race condition with a VCPU returning to user mode
and attempting to unregister the notifier.

Signed-off-by: Ignacio Alvarado <ikalvarado@google.com>
Cc: stable@vger.kernel.org
Fixes: 18863bdd60f8 ("KVM: x86 shared msr infrastructure")
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
(cherry picked from commit 1650b4ebc99da4c137bfbfc531be4a2405f951dd)

OraBug: 27623575
Signed-off-by: Allan Xavier <allan.x.xavier@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7 years agodtrace: increase instruction limit for FBT entry probe detection
Kris Van Hees [Thu, 18 Jan 2018 22:56:56 +0000 (17:56 -0500)]
dtrace: increase instruction limit for FBT entry probe detection

The logic used to detect whether we can place a FBT entry probe on
a function has a limit on how many instructions should be looked
at.  With the occurrence of longer function prologues, that limit
must be increased.  This commit changes it from 2 to 10.

Orabug: 27410742
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Tomas Jedlicka <tomas.jedlicka@oracle.com>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
7 years agotrace: declare blk_add_trace_rq non-static on OL6
Todd Vierling [Wed, 21 Feb 2018 15:55:39 +0000 (10:55 -0500)]
trace: declare blk_add_trace_rq non-static on OL6

In an external module, there is a reference to this function done
via explicit symbol lookup. The newer compiler used for retpoline
support on OL6 changes the symbol's asm name, which causes this lookup
to fail.

While it doesn't guarantee kABI compatibility, remove the "static"
qualifier for this function, on OL6 only, to allow continuing usage of
this code in the short term.

Orabug: 27578618
Signed-off-by: Todd Vierling <todd.vierling@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
7 years agox86/ia32/syscall: RESTORE_EXTRA_REGS when returning from syscall
Ankur Arora [Sat, 10 Feb 2018 03:25:21 +0000 (22:25 -0500)]
x86/ia32/syscall: RESTORE_EXTRA_REGS when returning from syscall

EXTRA_REGS (callee saved regs) are saved on kernel stack at entry and
zero'd. Some of these registers might be potentially used in the syscall
entry path and contain kernel state; to avoid leaking this state we
restore these registers as we exit to user-space.

Orabug: 27461990
CVE: CVE-2017-5715

Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agox86/ia32/syscall: don't do RESTORE_EXTRA_REGS prematurely
Ankur Arora [Thu, 8 Feb 2018 01:05:18 +0000 (20:05 -0500)]
x86/ia32/syscall: don't do RESTORE_EXTRA_REGS prematurely

With the recent spectre mitigation changes we save the full pt_regs on
the stack and zero the extra regs. This means that for the sysenter
(and cstar) calling conventions, the pt_regs state for %ebp contains
the user %esp instead of the 6th argument.

For the straight syscall (non-tracing) path we load the real %ebp from
the user-stack and all is well. In the tracing/seccomp path, however, we
do RESTORE_EXTRA_REGS before the syscall, thus clobbering the 6th
argument (which gets replaced with the old %ebp value.)

The fix is to RESTORE_EXTRA_REGS only if we are done with syscall
handling. A side benefit is that this mitigation now also extends to
the tracing path.

Orabug: 27461990
CVE: CVE-2017-5715

Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agofirmware: dmi_scan: add SBMIOS entry and DMI tables
Ivan Khoronzhuk [Thu, 25 Jun 2015 07:06:56 +0000 (09:06 +0200)]
firmware: dmi_scan: add SBMIOS entry and DMI tables

Orabug: 27586223

Some utils, like dmidecode and smbios, need to access SMBIOS entry
table area in order to get information like SMBIOS version, size, etc.
Currently it's done via /dev/mem. But for situation when /dev/mem
usage is disabled, the utils have to use dmi sysfs instead, which
doesn't represent SMBIOS entry and adds code/delay redundancy when direct
access for table is needed.

So this patch creates dmi/tables and adds SMBIOS entry point to allow
utils in question to work correctly without /dev/mem. Also patch adds
raw dmi table to simplify dmi table processing in user space, as
proposed by Jean Delvare.

Tested-by: Roy Franz <roy.franz@linaro.org>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@globallogic.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
(cherry picked from commit d7f96f97c4031fa4ffdb7801f9aae23e96170a6f)
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
Conflict:

MAINTAINERS

Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
(cherry picked from commit b9f88fe1e80c6b0178502ac52ba56251824e0e4a)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
7 years agouek-rpm: enable USERFAULTFD in debug kernels (UEK4 QU7)
Mike Kravetz [Tue, 20 Feb 2018 19:26:40 +0000 (11:26 -0800)]
uek-rpm: enable USERFAULTFD in debug kernels (UEK4 QU7)

Orabug: 27579702

UEK4 QU7 specific change to set CONFIG_USERFAULTFD=y in debug
config files.

Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed by: Victor Erminpour <victor.erminpour@oracle.com>

7 years agovmxnet3: repair memory leak
Neil Horman [Mon, 22 Jan 2018 21:06:37 +0000 (16:06 -0500)]
vmxnet3: repair memory leak

with the introduction of commit
b0eb57cb97e7837ebb746404c2c58c6f536f23fa, it appears that rq->buf_info
is improperly handled.  While it is heap allocated when an rx queue is
setup, and freed when torn down, an old line of code in
vmxnet3_rq_destroy was not properly removed, leading to rq->buf_info[0]
being set to NULL prior to its being freed, causing a memory leak, which
eventually exhausts the system on repeated create/destroy operations
(for example, when  the mtu of a vmxnet3 interface is changed
frequently.

Fix is pretty straight forward, just move the NULL set to after the
free.

Tested by myself with successful results

Applies to net, and should likely be queued for stable, please

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reported-By: boyang@redhat.com
CC: boyang@redhat.com
CC: Shrikrishna Khare <skhare@vmware.com>
CC: "VMware, Inc." <pv-drivers@vmware.com>
CC: David S. Miller <davem@davemloft.net>
Acked-by: Shrikrishna Khare <skhare@vmware.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27479086
(cherry picked from commit 848b159835ddef99cc4193083f7e786c3992f580)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
7 years agobonding: attempt to better support longer hw addresses
Jarod Wilson [Tue, 4 Apr 2017 21:32:42 +0000 (17:32 -0400)]
bonding: attempt to better support longer hw addresses

People are using bonding over Infiniband IPoIB connections, and who knows
what else. Infiniband has a hardware address length of 20 octets
(INFINIBAND_ALEN), and the network core defines a MAX_ADDR_LEN of 32.
Various places in the bonding code are currently hard-wired to 6 octets
(ETH_ALEN), such as the 3ad code, which I've left untouched here. Besides,
only alb is currently possible on Infiniband links right now anyway, due
to commit 1533e7731522, so the alb code is where most of the changes are.

One major component of this change is the addition of a bond_hw_addr_copy
function that takes a length argument, instead of using ether_addr_copy
everywhere that hardware addresses need to be copied about. The other
major component of this change is converting the bonding code from using
struct sockaddr for address storage to struct sockaddr_storage, as the
former has an address storage space of only 14, while the latter is 128
minus a few, which is necessary to support bonding over device with up to
MAX_ADDR_LEN octet hardware addresses. Additionally, this probably fixes
up some memory corruption issues with the current code, where it's
possible to write an infiniband hardware address into a sockaddr declared
on the stack.

Lightly tested on a dual mlx4 IPoIB setup, which properly shows a 20-octet
hardware address now:

$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: mlx4_ib0 (primary_reselect always)
Currently Active Slave: mlx4_ib0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 100
Down Delay (ms): 100

Slave Interface: mlx4_ib0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr:
80:00:02:08:fe:80:00:00:00:00:00:00:e4:1d:2d:03:00:1d:67:01
Slave queue ID: 0

Slave Interface: mlx4_ib1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr:
80:00:02:09:fe:80:00:00:00:00:00:01:e4:1d:2d:03:00:1d:67:02
Slave queue ID: 0

Also tested with a standard 1Gbps NIC bonding setup (with a mix of
e1000 and e1000e cards), running LNST's bonding tests.

CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Veaceslav Falico <vfalico@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit faeeb317a5615076dff1ff44b51e862e6064dbd0)

Orabug: 27542370

Gerd Rausch traced the stack corruption from 27535442 to this patch, so
I'm rolling it in with my other retpoline fix ("x86/spectre: move
microcode check before kernel ibrs flags are set").

Suggested-by: Gerd Rausch <gerd.rausch@oracle.com>
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Reviewed-by: Khalid Aziz <khalid.aziz@oracle.com>
7 years agoscsi: Make __scsi_remove_device go straight from BLOCKED to DEL
Bart Van Assche [Fri, 2 Jun 2017 21:21:57 +0000 (14:21 -0700)]
scsi: Make __scsi_remove_device go straight from BLOCKED to DEL

If a device is blocked, make __scsi_remove_device() cause it to
transition to the DEL state. This means that all the commands issued in
.shutdown() will error in the mid-layer, thus making the removal proceed
without being stopped.

This patch is a slightly modified version of a patch from James
Bottomley. This patch avoids that the following lockup occurs:

Call Trace:
 schedule+0x35/0x80
 schedule_timeout+0x237/0x2d0
 io_schedule_timeout+0xa6/0x110
 wait_for_completion_io+0xa3/0x110
 blk_execute_rq+0xdf/0x120
 scsi_execute+0xce/0x150 [scsi_mod]
 scsi_execute_req_flags+0x8f/0xf0 [scsi_mod]
 sd_sync_cache+0xa9/0x190 [sd_mod]
 sd_shutdown+0x6a/0x100 [sd_mod]
 sd_remove+0x64/0xc0 [sd_mod]
 __device_release_driver+0x8d/0x120
 device_release_driver+0x1e/0x30
 bus_remove_device+0xf9/0x170
 device_del+0x127/0x240
 __scsi_remove_device+0xc1/0xd0 [scsi_mod]
 scsi_forget_host+0x57/0x60 [scsi_mod]
 scsi_remove_host+0x72/0x110 [scsi_mod]
 srp_remove_work+0x8b/0x200 [ib_srp]

Reported-by: Israel Rukshin <israelr@mellanox.com>
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Israel Rukshin <israelr@mellanox.com>
Cc: Max Gurtovoy <maxg@mellanox.com>
Cc: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27546768
(cherry picked from commit 255ee9320e5dc46173bb94dbcd68e32f11fc10a9)
Signed-off-by: Kyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Conflicts:
drivers/scsi/scsi_sysfs.c

7 years agoscsi: Protect SCSI device state changes with a mutex
Bart Van Assche [Fri, 2 Jun 2017 21:21:55 +0000 (14:21 -0700)]
scsi: Protect SCSI device state changes with a mutex

Serializing SCSI device state changes avoids that two state changes can
occur concurrently, e.g. the state changes in scsi_target_block() and
__scsi_remove_device(). This serialization is essential to make patch
"Make __scsi_remove_device go straight from BLOCKED to DEL" work
reliably.

Enable this mechanism for all scsi_target_*block() callers but not for
the scsi_internal_device_unblock() calls from the mpt3sas driver because
that driver can call scsi_internal_device_unblock() from atomic context.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27546768
(cherry picked from commit 0db6ca8a5e1ea585795db3643ec7d50fc8cb1aff)
Signed-off-by: Kyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Conflicts:
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
include/scsi/scsi_device.h

Use kmalloc'd state_mutex_kabi in scsi_device to fit new field
state_mutex in KABI reserved space.

7 years agoscsi: Introduce scsi_start_queue()
Bart Van Assche [Fri, 2 Jun 2017 21:21:56 +0000 (14:21 -0700)]
scsi: Introduce scsi_start_queue()

This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Israel Rukshin <israelr@mellanox.com>
Cc: Max Gurtovoy <maxg@mellanox.com>
Cc: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27546768
(cherry picked from commit 66483a4a9f34427e3d6ec87d8e583f5d2a7cbb76)
Signed-off-by: Kyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoscsi: avoid a permanent stop of the scsi device's request queue
Wei Fang [Tue, 13 Dec 2016 01:25:21 +0000 (09:25 +0800)]
scsi: avoid a permanent stop of the scsi device's request queue

A race between scanning and fc_remote_port_delete() may result in a
permanent stop if the device gets blocked before scsi_sysfs_add_sdev()
and unblocked after.  The reason is that blocking a device sets both the
SDEV_BLOCKED state and the QUEUE_FLAG_STOPPED.  However,
scsi_sysfs_add_sdev() unconditionally sets SDEV_RUNNING which causes the
device to be ignored by scsi_target_unblock() and thus never have its
QUEUE_FLAG_STOPPED cleared leading to a device which is apparently
running but has a stopped queue.

We actually have two places where SDEV_RUNNING is set: once in
scsi_add_lun() which respects the blocked flag and once in
scsi_sysfs_add_sdev() which doesn't.  Since the second set is entirely
spurious, simply remove it to fix the problem.

Cc: <stable@vger.kernel.org>
Reported-by: Zengxi Chen <chenzengxi@huawei.com>
Signed-off-by: Wei Fang <fangwei1@huawei.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27546768
(cherry picked from commit d2a145252c52792bc59e4767b486b26c430af4bb)
Signed-off-by: Kyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
7 years agoIB/ipoib: ioctls IPOIBACLNADD and IPOIBACLNGET do not work correctly
Ka-Cheong Poon [Mon, 12 Feb 2018 16:39:21 +0000 (08:39 -0800)]
IB/ipoib: ioctls IPOIBACLNADD and IPOIBACLNGET do not work correctly

There is a problem in using the ips pointer in ipoib_do_ioctl().  It
does incorrect pointer arithmetic for the new ioctls since ips is an
u32 pointer.  It should use a struct in6_addr pointer instead of using
the ips pointer directly.  The end result is that it does not work
correctly if a list of ACLs are modified.

Orabug: 27533123

Signed-off-by: Ka-Cheong Poon <ka-cheong.poon@oracle.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
7 years agox86/spectre: move microcode check before kernel ibrs flags are set
Daniel Jordan [Tue, 13 Feb 2018 14:52:59 +0000 (06:52 -0800)]
x86/spectre: move microcode check before kernel ibrs flags are set

The check for bad spectre microcode, which prints "disabling
SPEC_CTRL/IBRS", happens after the kernel turns on its flags for "IBRS
supported" and "IBRS in use"

When the microcode check runs, it disables the CPU capability but the
kernel flags have already been set based on the disabled capability.

So to fix it, we should move the microcode check to before the kernel
flags are set.

Orabug: 27542331
CVE: CVE-2017-5715
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
7 years agox86: make HAVE_FENTRY dependent on !SIMULATE_GCC44_KABI
Todd Vierling [Tue, 13 Feb 2018 15:26:57 +0000 (10:26 -0500)]
x86: make HAVE_FENTRY dependent on !SIMULATE_GCC44_KABI

Something about the uek-rpm build doesn't always bubble config lines
down into the built RPMs properly. So force the issue by making use of
the special kABI flag introduced for OL6; if _not_ present, set
HAVE_FENTRY in its original place in arch/x86/Kconfig.

Orabug: 27540463
Signed-off-by: Todd Vierling <todd.vierling@oracle.com>
Reviewed-by: Victor Erminpour <victor.erminpour@oracle.com>