-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAl/99ZgACgkQONu9yGCS aT609BAAg3AcT6t2WQFfY0LZwaT4u8Y7mg7gx2995vDhzWOei/o6AasogDpnv+ey fDIu0NwMTK73K5bDSas5pWirEi/+eCk1S0xxg8rLkHgHOYJD7z6Ktq5DlNv5nfNN KUl1jnEcZznk4Y3ogxDwJTHmXVCRZAlckn46YiCpYKZeZbA/IqHlzzle9Dwd3eLN ElZN6Vdq5vagJOxTuFAEdHLy8mxIWySN0Kh6Ac0VKaaxLbE3GsXXEUtin7nLe/nj 19/98ije7vQaTUNdqMSu5FIQsZGHg+XNji7EGLvmF/nITEUdwzIWuMsP5/ArVpJn rjnmz2J3IuQix7X08PGcde/0T1scXxnspOrQyVnMgGEl9J/5NpewrIItGZGt3H0u /fTvohGXx1nvaavDii3u7/y+s038v9HeP9Br6ISlprwZP8Pg4arm0sPQ2aHbPQ1v GQZSqat6hOm8DvpkLr0mO4w/+RYgRaVLRCIf8jWoStPvS/pm4APaDvYPAjZdqPRm xPSOa9Irvg0UaiwIxiXJdPBvFELvUHexpSxTNGQWsXdNHfMROnK+B4c3MScbDVt8 vevIh3PVYqENW5Nsn7mSwdWPRzmNaouW/2fWqYjCWxhaSGfqweOz/JawHrwuTTQj GRdTgEn9w6o3uj8hQIt7c0+QfGLSvZlHfyvl7JYk/cV6SoofI40= =0wHl -----END PGP SIGNATURE----- Merge 5.4.89 into android11-5.4-lts Changes in 5.4.89 workqueue: Kick a worker based on the actual activation of delayed works scsi: ufs: Fix wrong print message in dev_err() scsi: ufs-pci: Ensure UFS device is in PowerDown mode for suspend-to-disk ->poweroff() scsi: ide: Do not set the RQF_PREEMPT flag for sense requests scsi: scsi_transport_spi: Set RQF_PM for domain validation commands lib/genalloc: fix the overflow when size is too big depmod: handle the case of /sbin/depmod without /sbin in PATH proc: change ->nlink under proc_subdir_lock proc: fix lookup in /proc/net subdirectories after setns(2) i40e: Fix Error I40E_AQ_RC_EINVAL when removing VFs iavf: fix double-release of rtnl_lock net: mvpp2: Add TCAM entry to drop flow control pause frames net: mvpp2: prs: fix PPPoE with ipv6 packet parse net: systemport: set dev->max_mtu to UMAC_MAX_MTU_SIZE ethernet: ucc_geth: fix use-after-free in ucc_geth_remove() ethernet: ucc_geth: set dev->max_mtu to 1518 atm: idt77252: call pci_disable_device() on error path net: mvpp2: Fix GoP port 3 Networking Complex Control configurations ibmvnic: continue fatal error reset after passive init net: ethernet: mvneta: Fix error handling in mvneta_probe qede: fix offload for IPIP tunnel packets virtio_net: Fix recursive call to cpus_read_lock() net/ncsi: Use real net-device for response handler net: ethernet: Fix memleak in ethoc_probe net-sysfs: take the rtnl lock when storing xps_cpus net-sysfs: take the rtnl lock when accessing xps_cpus_map and num_tc net-sysfs: take the rtnl lock when storing xps_rxqs net-sysfs: take the rtnl lock when accessing xps_rxqs_map and num_tc net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered tun: fix return value when the number of iovs exceeds MAX_SKB_FRAGS net: mvpp2: fix pkt coalescing int-threshold configuration ipv4: Ignore ECN bits for fib lookups in fib_compute_spec_dst() net: sched: prevent invalid Scell_log shift count net: hns: fix return value check in __lb_other_process() erspan: fix version 1 check in gre_parse_header() net: hdlc_ppp: Fix issues when mod_timer is called while timer is running r8169: work around power-saving bug on some chip versions net: dsa: lantiq_gswip: Enable GSWIP_MII_CFG_EN also for internal PHYs net: dsa: lantiq_gswip: Fix GSWIP_MII_CFG(p) register access CDC-NCM: remove "connected" log message net: usb: qmi_wwan: add Quectel EM160R-GL vhost_net: fix ubuf refcount incorrectly when sendmsg fails ionic: account for vlan tag len in rx buffer len net/sched: sch_taprio: ensure to reset/destroy all child qdiscs kbuild: don't hardcode depmod path Bluetooth: revert: hci_h5: close serdev device and free hu in h5_close video: hyperv_fb: Fix the mmap() regression for v5.4.y and older crypto: ecdh - avoid buffer overflow in ecdh_set_secret() crypto: asym_tpm: correct zero out potential secrets powerpc: Handle .text.{hot,unlikely}.* in linker script staging: mt7621-dma: Fix a resource leak in an error handling path usb: gadget: enable super speed plus USB: cdc-acm: blacklist another IR Droid device USB: cdc-wdm: Fix use after free in service_outstanding_interrupt(). usb: dwc3: ulpi: Use VStsDone to detect PHY regs access completion usb: chipidea: ci_hdrc_imx: add missing put_device() call in usbmisc_get_init_data() USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set usb: usbip: vhci_hcd: protect shift size usb: uas: Add PNY USB Portable SSD to unusual_uas USB: serial: iuu_phoenix: fix DMA from stack USB: serial: option: add LongSung M5710 module support USB: serial: option: add Quectel EM160R-GL USB: yurex: fix control-URB timeout handling USB: usblp: fix DMA to stack ALSA: usb-audio: Fix UBSAN warnings for MIDI jacks usb: gadget: select CONFIG_CRC32 usb: gadget: f_uac2: reset wMaxPacketSize usb: gadget: function: printer: Fix a memory leak for interface descriptor usb: gadget: u_ether: Fix MTU size mismatch with RX packet size USB: gadget: legacy: fix return error code in acm_ms_bind() usb: gadget: Fix spinlock lockup on usb_function_deactivate usb: gadget: configfs: Preserve function ordering after bind failure usb: gadget: configfs: Fix use-after-free issue with udc_name USB: serial: keyspan_pda: remove unused variable x86/mm: Fix leak of pmd ptlock kvm: check tlbs_dirty directly ALSA: hda/via: Fix runtime PM for Clevo W35xSS ALSA: hda/conexant: add a new hda codec CX11970 ALSA: hda/realtek - Fix speaker volume control on Lenovo C940 ALSA: hda/realtek: Enable mute and micmute LED on HP EliteBook 850 G7 ALSA: hda/realtek: Add two "Intel Reference board" SSID in the ALC256. btrfs: send: fix wrong file path when there is an inode with a pending rmdir Revert "device property: Keep secondary firmware node secondary by type" dmabuf: fix use-after-free of dmabuf's file->f_inode drm/i915: clear the gpu reloc batch netfilter: x_tables: Update remaining dereference to RCU netfilter: ipset: fix shift-out-of-bounds in htable_bits() netfilter: xt_RATEEST: reject non-null terminated string from userspace netfilter: nft_dynset: report EOPNOTSUPP on missing set feature x86/mtrr: Correct the range check before performing MTRR type lookups KVM: x86: fix shift out of bounds reported by UBSAN scsi: target: Fix XCOPY NAA identifier lookup Linux 5.4.89 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I38e853579d913e5db99c4c1dbd394c576af2f8b2
258 lines
6.6 KiB
C
258 lines
6.6 KiB
C
/*
|
|
* Universal Flash Storage Host controller PCI glue driver
|
|
*
|
|
* This code is based on drivers/scsi/ufs/ufshcd-pci.c
|
|
* Copyright (C) 2011-2013 Samsung India Software Operations
|
|
*
|
|
* Authors:
|
|
* Santosh Yaraganavi <santosh.sy@samsung.com>
|
|
* Vinayak Holikatti <h.vinayak@samsung.com>
|
|
*
|
|
* 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.
|
|
* See the COPYING file in the top-level directory or visit
|
|
* <http://www.gnu.org/licenses/gpl-2.0.html>
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* This program is provided "AS IS" and "WITH ALL FAULTS" and
|
|
* without warranty of any kind. You are solely responsible for
|
|
* determining the appropriateness of using and distributing
|
|
* the program and assume all risks associated with your exercise
|
|
* of rights with respect to the program, including but not limited
|
|
* to infringement of third party rights, the risks and costs of
|
|
* program errors, damage to or loss of data, programs or equipment,
|
|
* and unavailability or interruption of operations. Under no
|
|
* circumstances will the contributor of this Program be liable for
|
|
* any damages of any kind arising from your use or distribution of
|
|
* this program.
|
|
*/
|
|
|
|
#include "ufshcd.h"
|
|
#include <linux/pci.h>
|
|
#include <linux/pm_runtime.h>
|
|
|
|
static int ufs_intel_disable_lcc(struct ufs_hba *hba)
|
|
{
|
|
u32 attr = UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE);
|
|
u32 lcc_enable = 0;
|
|
|
|
ufshcd_dme_get(hba, attr, &lcc_enable);
|
|
if (lcc_enable)
|
|
ufshcd_disable_host_tx_lcc(hba);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ufs_intel_link_startup_notify(struct ufs_hba *hba,
|
|
enum ufs_notify_change_status status)
|
|
{
|
|
int err = 0;
|
|
|
|
switch (status) {
|
|
case PRE_CHANGE:
|
|
err = ufs_intel_disable_lcc(hba);
|
|
break;
|
|
case POST_CHANGE:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
static struct ufs_hba_variant_ops ufs_intel_cnl_hba_vops = {
|
|
.name = "intel-pci",
|
|
.link_startup_notify = ufs_intel_link_startup_notify,
|
|
};
|
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
/**
|
|
* ufshcd_pci_suspend - suspend power management function
|
|
* @dev: pointer to PCI device handle
|
|
*
|
|
* Returns 0 if successful
|
|
* Returns non-zero otherwise
|
|
*/
|
|
static int ufshcd_pci_suspend(struct device *dev)
|
|
{
|
|
return ufshcd_system_suspend(dev_get_drvdata(dev));
|
|
}
|
|
|
|
/**
|
|
* ufshcd_pci_resume - resume power management function
|
|
* @dev: pointer to PCI device handle
|
|
*
|
|
* Returns 0 if successful
|
|
* Returns non-zero otherwise
|
|
*/
|
|
static int ufshcd_pci_resume(struct device *dev)
|
|
{
|
|
return ufshcd_system_resume(dev_get_drvdata(dev));
|
|
}
|
|
|
|
/**
|
|
* ufshcd_pci_poweroff - suspend-to-disk poweroff function
|
|
* @dev: pointer to PCI device handle
|
|
*
|
|
* Returns 0 if successful
|
|
* Returns non-zero otherwise
|
|
*/
|
|
static int ufshcd_pci_poweroff(struct device *dev)
|
|
{
|
|
struct ufs_hba *hba = dev_get_drvdata(dev);
|
|
int spm_lvl = hba->spm_lvl;
|
|
int ret;
|
|
|
|
/*
|
|
* For poweroff we need to set the UFS device to PowerDown mode.
|
|
* Force spm_lvl to ensure that.
|
|
*/
|
|
hba->spm_lvl = 5;
|
|
ret = ufshcd_system_suspend(hba);
|
|
hba->spm_lvl = spm_lvl;
|
|
return ret;
|
|
}
|
|
|
|
#endif /* !CONFIG_PM_SLEEP */
|
|
|
|
#ifdef CONFIG_PM
|
|
static int ufshcd_pci_runtime_suspend(struct device *dev)
|
|
{
|
|
return ufshcd_runtime_suspend(dev_get_drvdata(dev));
|
|
}
|
|
static int ufshcd_pci_runtime_resume(struct device *dev)
|
|
{
|
|
return ufshcd_runtime_resume(dev_get_drvdata(dev));
|
|
}
|
|
static int ufshcd_pci_runtime_idle(struct device *dev)
|
|
{
|
|
return ufshcd_runtime_idle(dev_get_drvdata(dev));
|
|
}
|
|
#endif /* !CONFIG_PM */
|
|
|
|
/**
|
|
* ufshcd_pci_shutdown - main function to put the controller in reset state
|
|
* @pdev: pointer to PCI device handle
|
|
*/
|
|
static void ufshcd_pci_shutdown(struct pci_dev *pdev)
|
|
{
|
|
ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
|
|
}
|
|
|
|
/**
|
|
* ufshcd_pci_remove - de-allocate PCI/SCSI host and host memory space
|
|
* data structure memory
|
|
* @pdev: pointer to PCI handle
|
|
*/
|
|
static void ufshcd_pci_remove(struct pci_dev *pdev)
|
|
{
|
|
struct ufs_hba *hba = pci_get_drvdata(pdev);
|
|
|
|
pm_runtime_forbid(&pdev->dev);
|
|
pm_runtime_get_noresume(&pdev->dev);
|
|
ufshcd_remove(hba);
|
|
ufshcd_dealloc_host(hba);
|
|
}
|
|
|
|
/**
|
|
* ufshcd_pci_probe - probe routine of the driver
|
|
* @pdev: pointer to PCI device handle
|
|
* @id: PCI device id
|
|
*
|
|
* Returns 0 on success, non-zero value on failure
|
|
*/
|
|
static int
|
|
ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|
{
|
|
struct ufs_hba *hba;
|
|
void __iomem *mmio_base;
|
|
int err;
|
|
|
|
err = pcim_enable_device(pdev);
|
|
if (err) {
|
|
dev_err(&pdev->dev, "pcim_enable_device failed\n");
|
|
return err;
|
|
}
|
|
|
|
pci_set_master(pdev);
|
|
|
|
err = pcim_iomap_regions(pdev, 1 << 0, UFSHCD);
|
|
if (err < 0) {
|
|
dev_err(&pdev->dev, "request and iomap failed\n");
|
|
return err;
|
|
}
|
|
|
|
mmio_base = pcim_iomap_table(pdev)[0];
|
|
|
|
err = ufshcd_alloc_host(&pdev->dev, &hba);
|
|
if (err) {
|
|
dev_err(&pdev->dev, "Allocation failed\n");
|
|
return err;
|
|
}
|
|
|
|
hba->vops = (struct ufs_hba_variant_ops *)id->driver_data;
|
|
|
|
err = ufshcd_init(hba, mmio_base, pdev->irq);
|
|
if (err) {
|
|
dev_err(&pdev->dev, "Initialization failed\n");
|
|
ufshcd_dealloc_host(hba);
|
|
return err;
|
|
}
|
|
|
|
pci_set_drvdata(pdev, hba);
|
|
pm_runtime_put_noidle(&pdev->dev);
|
|
pm_runtime_allow(&pdev->dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct dev_pm_ops ufshcd_pci_pm_ops = {
|
|
#ifdef CONFIG_PM_SLEEP
|
|
.suspend = ufshcd_pci_suspend,
|
|
.resume = ufshcd_pci_resume,
|
|
.freeze = ufshcd_pci_suspend,
|
|
.thaw = ufshcd_pci_resume,
|
|
.poweroff = ufshcd_pci_poweroff,
|
|
.restore = ufshcd_pci_resume,
|
|
#endif
|
|
SET_RUNTIME_PM_OPS(ufshcd_pci_runtime_suspend,
|
|
ufshcd_pci_runtime_resume,
|
|
ufshcd_pci_runtime_idle)
|
|
};
|
|
|
|
static const struct pci_device_id ufshcd_pci_tbl[] = {
|
|
{ PCI_VENDOR_ID_SAMSUNG, 0xC00C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
|
|
{ PCI_VDEVICE(INTEL, 0x9DFA), (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
|
|
{ PCI_VDEVICE(INTEL, 0x4B41), (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
|
|
{ PCI_VDEVICE(INTEL, 0x4B43), (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
|
|
{ } /* terminate list */
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, ufshcd_pci_tbl);
|
|
|
|
static struct pci_driver ufshcd_pci_driver = {
|
|
.name = UFSHCD,
|
|
.id_table = ufshcd_pci_tbl,
|
|
.probe = ufshcd_pci_probe,
|
|
.remove = ufshcd_pci_remove,
|
|
.shutdown = ufshcd_pci_shutdown,
|
|
.driver = {
|
|
.pm = &ufshcd_pci_pm_ops
|
|
},
|
|
};
|
|
|
|
module_pci_driver(ufshcd_pci_driver);
|
|
|
|
MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>");
|
|
MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
|
|
MODULE_DESCRIPTION("UFS host controller PCI glue driver");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_VERSION(UFSHCD_DRIVER_VERSION);
|