mailweb.openeuler.org
Manage this list

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

Kernel

Threads by month
  • ----- 2025 -----
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
kernel@openeuler.org

July 2021

  • 15 participants
  • 107 discussions
[PATCH OLK-5.10 0/3] Add support of Zhaoxin HDAC and codec
by LeoLiuoc 09 Jul '21

09 Jul '21
Zhaoxin have new SB & NB HDAC controller. And have new NB HDAC codec. This patch set add support for them. LeoLiu-oc (3):   ALSA: hda: Add Zhaoxin SB HDAC non snoop path support   ALSA: hda: Add support of Zhaoxin NB HDAC   ALSA: hda: Add support of Zhaoxin NB HDAC codec  sound/pci/hda/hda_controller.c | 17 ++++++++-  sound/pci/hda/hda_controller.h |  2 ++  sound/pci/hda/hda_intel.c      | 64 ++++++++++++++++++++++++++++++++--  sound/pci/hda/patch_hdmi.c     | 26 ++++++++++++++  4 files changed, 106 insertions(+), 3 deletions(-) -- 2.20.1
1 0
0 0
[PATCH OLK-5.10] xhci: Show Zhaoxin XHCI root hub speed correctly
by LeoLiuoc 09 Jul '21

09 Jul '21
Some Zhaoxin xHCI controllers follow usb3.1 spec, but only support gen1 speed 5G. While in Linux kernel, if xHCI suspport usb3.1,root hub speed will show on 10G. To fix this issue, read usb speed ID supported by xHCI to determine root hub speed. Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com> ---  drivers/usb/host/xhci.c | 19 +++++++++++++++++++  1 file changed, 19 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index a834f3927bee..e9d67ee299d9 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5186,6 +5186,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)       */      struct device        *dev = hcd->self.sysdev;      unsigned int        minor_rev; +    u8            i, j;      int            retval;      /* Accept arbitrarily long scatter-gather lists */ @@ -5240,6 +5241,24 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)              hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS;              break;          } + +        /* usb3.1 has gen1 and gen2, Some zx's xHCI controller that follow usb3.1 spec +         * but only support gen1 +         */ +        if (xhci->quirks & XHCI_ZHAOXIN_HOST) { +            minor_rev = 0; +            for (j = 0; j < xhci->num_port_caps; j++) { +                for (i = 0; i < xhci->port_caps[j].psi_count; i++) { +                    if (XHCI_EXT_PORT_PSIV(xhci->port_caps[j].psi[i]) >= 5) +                        minor_rev = 1; +                } +                if (minor_rev != 1) { +                    hcd->speed = HCD_USB3; +                    hcd->self.root_hub->speed = USB_SPEED_SUPER; +                } +            } +        } +          xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n",                minor_rev,                minor_rev ? "Enhanced " : ""); -- 2.20.1
1 0
0 0
[PATCH OLK-5.10] xhci: fix issue of cross page boundary in TRB prefetch
by LeoLiuoc 09 Jul '21

09 Jul '21
On some Zhaoxin platforms, xHCI will prefetch TRB for performance improvement. However this TRB prefetch mechanism may cross page boundary, which may access memory not belong to xHCI. In order to fix this issue, using two pages for TRB allocate and only the first page will be used. Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com> ---  drivers/usb/host/xhci-mem.c | 10 +++++++++-  drivers/usb/host/xhci-pci.c |  5 +++++  drivers/usb/host/xhci.h     |  1 +  3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 8ce043e6ed87..67329b4188cf 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2458,8 +2458,16 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)       * and our use of dma addresses in the trb_address_map radix tree needs       * TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need.       */ -    xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, +    /* With xHCI TRB prefetch patch:To fix cross page boundary access issue +     * in IOV environment +     */ +    if (xhci->quirks & XHCI_ZHAOXIN_TRB_FETCH) { +        xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, +            TRB_SEGMENT_SIZE*2, TRB_SEGMENT_SIZE*2, xhci->page_size*2); +    } else { +        xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,              TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size); +    }      /* See Table 46 and Note on Figure 55 */      xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev, diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index e78316ed99d4..471cf3e96032 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -281,6 +281,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)      if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483)          xhci->quirks |= XHCI_LPM_SUPPORT; +    if (pdev->vendor == PCI_VENDOR_ID_ZHAOXIN && +        (pdev->device == 0x9202 || +         pdev->device == 0x9203)) +        xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH; +      if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&          pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI)          xhci->quirks |= XHCI_BROKEN_STREAMS; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 576cafb5d873..e215431f927a 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1881,6 +1881,7 @@ struct xhci_hcd {  #define XHCI_SG_TRB_CACHE_SIZE_QUIRK    BIT_ULL(39)  #define XHCI_NO_SOFT_RETRY    BIT_ULL(40)  #define XHCI_ZHAOXIN_HOST    BIT_ULL(41) +#define XHCI_ZHAOXIN_TRB_FETCH    BIT_ULL(42)      unsigned int        num_active_eps;      unsigned int        limit_active_eps; -- 2.20.1
1 0
0 0
[PATCH OLK-5.10] xhci: Add Zhaoxin xHCI LPM U1/U2 feature support
by LeoLiuoc 09 Jul '21

09 Jul '21
Add LPM u1/u2 feature support for xHCI of zhaoxin Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com> ---  drivers/usb/host/xhci-pci.c |  4 ++++  drivers/usb/host/xhci.c     | 34 ++++++++++++++++++++++++++++++++--  drivers/usb/host/xhci.h     |  1 +  3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 7bc18cf8042c..e78316ed99d4 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -268,6 +268,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)      }      if (pdev->vendor == PCI_VENDOR_ID_VIA)          xhci->quirks |= XHCI_RESET_ON_RESUME; +    if (pdev->vendor == PCI_VENDOR_ID_ZHAOXIN) { +        xhci->quirks |= XHCI_LPM_SUPPORT; +        xhci->quirks |= XHCI_ZHAOXIN_HOST; +    }      /* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */      if (pdev->vendor == PCI_VENDOR_ID_VIA && diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index a8d97e23f601..a834f3927bee 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4666,7 +4666,7 @@ static u16 xhci_calculate_u1_timeout(struct xhci_hcd *xhci,  {      unsigned long long timeout_ns; -    if (xhci->quirks & XHCI_INTEL_HOST) +    if (xhci->quirks & (XHCI_INTEL_HOST | XHCI_ZHAOXIN_HOST))          timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);      else          timeout_ns = udev->u1_params.sel; @@ -4730,7 +4730,7 @@ static u16 xhci_calculate_u2_timeout(struct xhci_hcd *xhci,  {      unsigned long long timeout_ns; -    if (xhci->quirks & XHCI_INTEL_HOST) +    if (xhci->quirks & (XHCI_INTEL_HOST | XHCI_ZHAOXIN_HOST))          timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);      else          timeout_ns = udev->u2_params.sel; @@ -4835,12 +4835,42 @@ static int xhci_check_intel_tier_policy(struct usb_device *udev,      return -E2BIG;  } +static int xhci_check_zhaoxin_tier_policy(struct usb_device *udev, +                            enum usb3_link_state state) +{ +    struct usb_device *parent; +    unsigned int num_hubs; +    char *state_name; + +    if (state == USB3_LPM_U1) +        state_name = "U1"; +    else if (state == USB3_LPM_U2) +        state_name = "U2"; +    else +        state_name = "Unknown"; +    /* Don't enable U1/U2 if the device is on an external hub*/ +    for (parent = udev->parent, num_hubs = 0; parent->parent; +            parent = parent->parent) +            num_hubs++; + +    if (num_hubs < 1) +        return 0; + +    dev_dbg(&udev->dev, "Disabling %s link state for device" +            " below external hub.\n", state_name); +    dev_dbg(&udev->dev, "Plug device into root port " +            "to decrease power consumption.\n"); +    return -E2BIG; +} +  static int xhci_check_tier_policy(struct xhci_hcd *xhci,          struct usb_device *udev,          enum usb3_link_state state)  {      if (xhci->quirks & XHCI_INTEL_HOST)          return xhci_check_intel_tier_policy(udev, state); +    else if (xhci->quirks & XHCI_ZHAOXIN_HOST) +        return xhci_check_zhaoxin_tier_policy(udev, state);      else          return 0;  } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index d01241f1daf3..576cafb5d873 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1880,6 +1880,7 @@ struct xhci_hcd {  #define XHCI_DISABLE_SPARSE    BIT_ULL(38)  #define XHCI_SG_TRB_CACHE_SIZE_QUIRK    BIT_ULL(39)  #define XHCI_NO_SOFT_RETRY    BIT_ULL(40) +#define XHCI_ZHAOXIN_HOST    BIT_ULL(41)      unsigned int        num_active_eps;      unsigned int        limit_active_eps; -- 2.20.1
1 0
0 0
[PATCH OLK-5.10] ata: sata_zhaoxin: Add support for Zhaoxin Serial ATA
by LeoLiuoc 09 Jul '21

09 Jul '21
Add Zhaoxin Serial ATA support for Zhaoxin CPUs. Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com> ---  drivers/ata/Kconfig        |   8 +  drivers/ata/Makefile       |   1 +  drivers/ata/sata_zhaoxin.c | 384 +++++++++++++++++++++++++++++++++++++  3 files changed, 393 insertions(+)  create mode 100644 drivers/ata/sata_zhaoxin.c diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 030cb32da980..5f62dcdc546b 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -552,6 +552,14 @@ config SATA_VITESSE        If unsure, say N. +config SATA_ZHAOXIN +    tristate "ZhaoXin SATA support" +    depends on PCI +    help +      This option enables support for ZhaoXin Serial ATA. + +      If unsure, say N. +  comment "PATA SFF controllers with BMDMA"  config PATA_ALI diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index b8aebfb14e82..9a3ce171d9e8 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_SATA_SVW)        += sata_svw.o  obj-$(CONFIG_SATA_ULI)        += sata_uli.o  obj-$(CONFIG_SATA_VIA)        += sata_via.o  obj-$(CONFIG_SATA_VITESSE)    += sata_vsc.o +obj-$(CONFIG_SATA_ZHAOXIN)        += sata_zhaoxin.o  # SFF PATA w/ BMDMA  obj-$(CONFIG_PATA_ALI)        += pata_ali.o diff --git a/drivers/ata/sata_zhaoxin.c b/drivers/ata/sata_zhaoxin.c new file mode 100644 index 000000000000..8e30a6525f54 --- /dev/null +++ b/drivers/ata/sata_zhaoxin.c @@ -0,0 +1,384 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + *  sata_zhaoxin.c - ZhaoXin Serial ATA controllers + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/blkdev.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <scsi/scsi.h> +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_host.h> +#include <linux/libata.h> + +#define DRV_NAME    "sata_zx" +#define DRV_VERSION    "2.6.1" + +enum board_ids_enum { +    cnd001, +}; + +enum { +    SATA_CHAN_ENAB        = 0x40, /* SATA channel enable */ +    SATA_INT_GATE        = 0x41, /* SATA interrupt gating */ +    SATA_NATIVE_MODE    = 0x42, /* Native mode enable */ +    PATA_UDMA_TIMING    = 0xB3, /* PATA timing for DMA/ cable detect */ +    PATA_PIO_TIMING        = 0xAB, /* PATA timing register */ + +    PORT0            = (1 << 1), +    PORT1            = (1 << 0), +    ALL_PORTS        = PORT0 | PORT1, + +    NATIVE_MODE_ALL        = (1 << 7) | (1 << 6) | (1 << 5) | (1 << 4), + +    SATA_EXT_PHY        = (1 << 6), /* 0==use PATA, 1==ext phy */ +}; + +static int szx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static int cnd001_scr_read(struct ata_link *link, unsigned int scr, u32 *val); +static int cnd001_scr_write(struct ata_link *link, unsigned int scr, u32 val); +static int szx_hardreset(struct ata_link *link, unsigned int *class, +                unsigned long deadline); + +static void szx_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); + +static const struct pci_device_id szx_pci_tbl[] = { +    { PCI_VDEVICE(ZHAOXIN, 0x9002), cnd001 }, +    { PCI_VDEVICE(ZHAOXIN, 0x9003), cnd001 }, + +    { }    /* terminate list */ +}; + +static struct pci_driver szx_pci_driver = { +    .name            = DRV_NAME, +    .id_table        = szx_pci_tbl, +    .probe            = szx_init_one, +#ifdef CONFIG_PM_SLEEP +    .suspend        = ata_pci_device_suspend, +    .resume            = ata_pci_device_resume, +#endif +    .remove            = ata_pci_remove_one, +}; + +static struct scsi_host_template szx_sht = { +    ATA_BMDMA_SHT(DRV_NAME), +}; + +static struct ata_port_operations szx_base_ops = { +    .inherits        = &ata_bmdma_port_ops, +    .sff_tf_load        = szx_tf_load, +}; + +static struct ata_port_operations cnd001_ops = { +    .inherits        = &szx_base_ops, +    .hardreset        = szx_hardreset, +    .scr_read        = cnd001_scr_read, +    .scr_write        = cnd001_scr_write, +}; + +static struct ata_port_info cnd001_port_info = { +    .flags        = ATA_FLAG_SATA | ATA_FLAG_SLAVE_POSS, +    .pio_mask    = ATA_PIO4, +    .mwdma_mask    = ATA_MWDMA2, +    .udma_mask    = ATA_UDMA6, +    .port_ops    = &cnd001_ops, +}; + + +static int szx_hardreset(struct ata_link *link, unsigned int *class, +                unsigned long deadline) +{ +    int rc; + +    rc = sata_std_hardreset(link, class, deadline); +    if (!rc || rc == -EAGAIN) { +        struct ata_port *ap = link->ap; +        int pmp = link->pmp; +        int tmprc; + +        if (pmp) { +            ap->ops->sff_dev_select(ap, pmp); +            tmprc = ata_sff_wait_ready(&ap->link, deadline); +        } else { +            tmprc = ata_sff_wait_ready(link, deadline); +        } +        if (tmprc) +            ata_link_err(link, "COMRESET failed for wait (errno=%d)\n", +                    rc); +        else +            ata_link_err(link, "wait for bsy success\n"); + +        ata_link_err(link, "COMRESET success (errno=%d) ap=%d link %d\n", +                    rc, link->ap->port_no, link->pmp); +    } else { +        ata_link_err(link, "COMRESET failed (errno=%d) ap=%d link %d\n", +                    rc, link->ap->port_no, link->pmp); +    } +    return rc; +} + +static int cnd001_scr_read(struct ata_link *link, unsigned int scr, u32 *val) +{ +    static const u8 ipm_tbl[] = { 1, 2, 6, 0 }; +    struct pci_dev *pdev = to_pci_dev(link->ap->host->dev); +    int slot = 2 * link->ap->port_no + link->pmp; +    u32 v = 0; +    u8 raw; + +    switch (scr) { +    case SCR_STATUS: +        pci_read_config_byte(pdev, 0xA0 + slot, &raw); + +        /* read the DET field, bit0 and 1 of the config byte */ +        v |= raw & 0x03; + +        /* read the SPD field, bit4 of the configure byte */ +        v |= raw & 0x30; + +        /* read the IPM field, bit2 and 3 of the config byte */ +        v |= ((ipm_tbl[(raw >> 2) & 0x3])<<8); +        break; + +    case SCR_ERROR: +        /* devices other than 5287 uses 0xA8 as base */ +        WARN_ON(pdev->device != 0x9002 && pdev->device != 0x9003); +        pci_write_config_byte(pdev, 0x42, slot); +        pci_read_config_dword(pdev, 0xA8, &v); +        break; + +    case SCR_CONTROL: +        pci_read_config_byte(pdev, 0xA4 + slot, &raw); + +        /* read the DET field, bit0 and bit1 */ +        v |= ((raw & 0x02) << 1) | (raw & 0x01); + +        /* read the IPM field, bit2 and bit3 */ +        v |= ((raw >> 2) & 0x03) << 8; + +        break; + +    default: +        return -EINVAL; +    } + +    *val = v; +    return 0; +} + +static int cnd001_scr_write(struct ata_link *link, unsigned int scr, u32 val) +{ +    struct pci_dev *pdev = to_pci_dev(link->ap->host->dev); +    int slot = 2 * link->ap->port_no + link->pmp; +    u32 v = 0; + +    WARN_ON(pdev == NULL); + +    switch (scr) { +    case SCR_ERROR: +        /* devices 0x9002 uses 0xA8 as base */ +        WARN_ON(pdev->device != 0x9002 && pdev->device != 0x9003); +        pci_write_config_byte(pdev, 0x42, slot); +        pci_write_config_dword(pdev, 0xA8, val); +        return 0; + +    case SCR_CONTROL: +        /* set the DET field */ +        v |= ((val & 0x4) >> 1) | (val & 0x1); + +        /* set the IPM field */ +        v |= ((val >> 8) & 0x3) << 2; + + +        pci_write_config_byte(pdev, 0xA4 + slot, v); + + +        return 0; + +    default: +        return -EINVAL; +    } +} + + +/** + *    szx_tf_load - send taskfile registers to host controller + *    @ap: Port to which output is sent + *    @tf: ATA taskfile register set + * + *    Outputs ATA taskfile to standard ATA host controller. + * + *    This is to fix the internal bug of zx chipsets, which will + *    reset the device register after changing the IEN bit on ctl + *    register. + */ +static void szx_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) +{ +    struct ata_taskfile ttf; + +    if (tf->ctl != ap->last_ctl)  { +        ttf = *tf; +        ttf.flags |= ATA_TFLAG_DEVICE; +        tf = &ttf; +    } +    ata_sff_tf_load(ap, tf); +} + +static const unsigned int szx_bar_sizes[] = { +    8, 4, 8, 4, 16, 256 +}; + +static const unsigned int cnd001_bar_sizes0[] = { +    8, 4, 8, 4, 16, 0 +}; + +static const unsigned int cnd001_bar_sizes1[] = { +    8, 4, 0, 0, 16, 0 +}; + +static int cnd001_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) +{ +    const struct ata_port_info *ppi0[] = { +        &cnd001_port_info, NULL +    }; +    const struct ata_port_info *ppi1[] = { +        &cnd001_port_info, &ata_dummy_port_info +    }; +    struct ata_host *host; +    int i, rc; + +    if (pdev->device == 0x9002) +        rc = ata_pci_bmdma_prepare_host(pdev, ppi0, &host); +    else if (pdev->device == 0x9003) +        rc = ata_pci_bmdma_prepare_host(pdev, ppi1, &host); +    else +        rc = -EINVAL; + +    if (rc) +        return rc; + +    *r_host = host; + +    /* cnd001 9002 hosts four sata ports as M/S of the two channels */ +    /* cnd001 9003 hosts two sata ports as M/S of the one channel */ +    for (i = 0; i < host->n_ports; i++) +        ata_slave_link_init(host->ports[i]); + +    return 0; +} + +static void szx_configure(struct pci_dev *pdev, int board_id) +{ +    u8 tmp8; + +    pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8); +    dev_info(&pdev->dev, "routed to hard irq line %d\n", +        (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f); + +    /* make sure SATA channels are enabled */ +    pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8); +    if ((tmp8 & ALL_PORTS) != ALL_PORTS) { +        dev_dbg(&pdev->dev, "enabling SATA channels (0x%x)\n", +            (int)tmp8); +        tmp8 |= ALL_PORTS; +        pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); +    } + +    /* make sure interrupts for each channel sent to us */ +    pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8); +    if ((tmp8 & ALL_PORTS) != ALL_PORTS) { +        dev_dbg(&pdev->dev, "enabling SATA channel interrupts (0x%x)\n", +            (int) tmp8); +        tmp8 |= ALL_PORTS; +        pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); +    } + +    /* make sure native mode is enabled */ +    pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8); +    if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { +        dev_dbg(&pdev->dev, +            "enabling SATA channel native mode (0x%x)\n", +            (int) tmp8); +        tmp8 |= NATIVE_MODE_ALL; +        pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); +    } +} + +static int szx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +{ +    unsigned int i; +    int rc; +    struct ata_host *host = NULL; +    int board_id = (int) ent->driver_data; +    const unsigned int *bar_sizes; +    int legacy_mode = 0; + +    ata_print_version_once(&pdev->dev, DRV_VERSION); + +    if (pdev->device == 0x9002 || pdev->device == 0x9003) { +        if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { +            u8 tmp8, mask; + +            /* TODO: What if one channel is in native mode ... */ +            pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); +            mask = (1 << 2) | (1 << 0); +            if ((tmp8 & mask) != mask) +                legacy_mode = 1; +        } +        if (legacy_mode) +            return -EINVAL; +    } + +    rc = pcim_enable_device(pdev); +    if (rc) +        return rc; + +    if (board_id == cnd001 && pdev->device == 0x9002) +        bar_sizes = &cnd001_bar_sizes0[0]; +    else if (board_id == cnd001 && pdev->device == 0x9003) +        bar_sizes = &cnd001_bar_sizes1[0]; +    else +        bar_sizes = &szx_bar_sizes[0]; + +    for (i = 0; i < ARRAY_SIZE(szx_bar_sizes); i++) { +        if ((pci_resource_start(pdev, i) == 0) || +            (pci_resource_len(pdev, i) < bar_sizes[i])) { +            if (bar_sizes[i] == 0) +                continue; + +            dev_err(&pdev->dev, +                "invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n", +                i, +                (unsigned long long)pci_resource_start(pdev, i), +                (unsigned long long)pci_resource_len(pdev, i)); + +            return -ENODEV; +        } +    } + +    switch (board_id) { +    case cnd001: +        rc = cnd001_prepare_host(pdev, &host); +        break; +    default: +        rc = -EINVAL; +    } +    if (rc) +        return rc; + +    szx_configure(pdev, board_id); + +    pci_set_master(pdev); +    return ata_host_activate(host, pdev->irq, ata_bmdma_interrupt, +                IRQF_SHARED, &szx_sht); +} + +module_pci_driver(szx_pci_driver); + +MODULE_AUTHOR("Yanchen:YanchenSun@zhaoxin.com"); +MODULE_DESCRIPTION("SCSI low-level driver for ZX SATA controllers"); +MODULE_LICENSE("GPL"); +MODULE_DEVICE_TABLE(pci, szx_pci_tbl); +MODULE_VERSION(DRV_VERSION); -- 2.20.1
1 0
0 0
[PATCH OLK-5.10] crypto: x86/crc32c-intel - Don't match some Zhaoxin CPUs
by LeoLiuoc 09 Jul '21

09 Jul '21
The driver crc32c-intel match CPUs supporting X86_FEATURE_XMM4_2. On platforms with Zhaoxin CPUs supporting this X86 feature, when crc32c-intel and crc32c-generic are both registered, system will use crc32c-intel because its .cra_priority is greater than crc32c-generic. When doing lmbench3 Create and Delete file test on partitions with ext4 enabling metadata checksum, found using crc32c-generic driver could get about 20% performance gain than using the driver crc32c-intel on some Zhaoxin CPUs. This case expect to use crc32c-generic driver for these Zhaoxin CPUs to get performance gain, so remove these Zhaoxin CPUs support from crc32c-intel. This patch was submitted to mainline kernel but not accepted by upstream maintainer whose reason is "Then create a BUG flag for it,". We think this is not a CPU bug for Zhaoxin CPUs. So should patch the crc32c driver for Zhaoxin CPUs but not report a BUG. https://lkml.org/lkml/2020/12/11/308 Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com> ---  arch/x86/crypto/crc32c-intel_glue.c | 8 ++++++++  1 file changed, 8 insertions(+) diff --git a/arch/x86/crypto/crc32c-intel_glue.c b/arch/x86/crypto/crc32c-intel_glue.c index feccb5254c7e..2d7fe5d24f5f 100644 --- a/arch/x86/crypto/crc32c-intel_glue.c +++ b/arch/x86/crypto/crc32c-intel_glue.c @@ -222,8 +222,16 @@ MODULE_DEVICE_TABLE(x86cpu, crc32c_cpu_id);  static int __init crc32c_intel_mod_init(void)  { +    struct cpuinfo_x86 *c = &boot_cpu_data; +      if (!x86_match_cpu(crc32c_cpu_id))          return -ENODEV; + +    if ((c->x86_vendor == X86_VENDOR_ZHAOXIN || c->x86_vendor == X86_VENDOR_CENTAUR) && +        (c->x86 <= 7 && c->x86_model <= 59)) { +            return -ENODEV; +    } +  #ifdef CONFIG_X86_64      if (boot_cpu_has(X86_FEATURE_PCLMULQDQ)) {          alg.update = crc32c_pcl_intel_update; -- 2.20.1
1 0
0 0
[PATCH OLK-5.10] Add MCA supprot for X86_VENDOR_CENTAUR CPUs
by LeoLiuoc 09 Jul '21

09 Jul '21
Add MCA support for some Zhaoxin CPUs which use X86_VENDOR_CENTAUR as vendor ID. Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com> ---  arch/x86/kernel/cpu/mce/core.c  | 39 ++++++++++++---------------------  arch/x86/kernel/cpu/mce/intel.c |  3 ++-  2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index b7a27589dfa0..aca6ab19726f 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -538,7 +538,8 @@ int mce_usable_address(struct mce *m)      /* Checks after this one are Intel/Zhaoxin-specific: */      if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL && -        boot_cpu_data.x86_vendor != X86_VENDOR_ZHAOXIN) +        boot_cpu_data.x86_vendor != X86_VENDOR_CENTAUR && +        boot_cpu_data.x86_vendor != X86_VENDOR_ZHAOXIN)          return 1;      if (!(m->status & MCI_STATUS_MISCV)) @@ -562,6 +563,7 @@ bool mce_is_memory_error(struct mce *m)          return amd_mce_is_memory_error(m);      case X86_VENDOR_INTEL: +    case X86_VENDOR_CENTAUR:      case X86_VENDOR_ZHAOXIN:          /*           * Intel SDM Volume 3B - 15.9.2 Compound Error Codes @@ -1155,7 +1157,8 @@ static noinstr bool mce_check_crashing_cpu(void)          mcgstatus = __rdmsr(MSR_IA32_MCG_STATUS); -        if (boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) { +        if (boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR || +            boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) {              if (mcgstatus & MCG_STATUS_LMCES)                  return false;          } @@ -1358,7 +1361,8 @@ noinstr void do_machine_check(struct pt_regs *regs)       * on Intel, Zhaoxin only.       */      if (m.cpuvendor == X86_VENDOR_INTEL || -        m.cpuvendor == X86_VENDOR_ZHAOXIN) +        m.cpuvendor == X86_VENDOR_CENTAUR || +        m.cpuvendor == X86_VENDOR_ZHAOXIN)          lmce = m.mcgstatus & MCG_STATUS_LMCES;      /* @@ -1786,7 +1790,8 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)              quirk_no_way_out = quirk_sandybridge_ifu;      } -    if (c->x86_vendor == X86_VENDOR_ZHAOXIN) { +    if (c->x86_vendor == X86_VENDOR_CENTAUR || +        c->x86_vendor == X86_VENDOR_ZHAOXIN) {          /*           * All newer Zhaoxin CPUs support MCE broadcasting. Enable           * synchronization with a one second timeout. @@ -1846,21 +1851,6 @@ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c)      }  } -static void mce_centaur_feature_init(struct cpuinfo_x86 *c) -{ -    struct mca_config *cfg = &mca_cfg; - -     /* -      * All newer Centaur CPUs support MCE broadcasting. Enable -      * synchronization with a one second timeout. -      */ -    if ((c->x86 == 6 && c->x86_model == 0xf && c->x86_stepping >= 0xe) || -         c->x86 > 6) { -        if (cfg->monarch_timeout < 0) -            cfg->monarch_timeout = USEC_PER_SEC; -    } -} -  static void mce_zhaoxin_feature_init(struct cpuinfo_x86 *c)  {      struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); @@ -1908,9 +1898,6 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)          break;      case X86_VENDOR_CENTAUR: -        mce_centaur_feature_init(c); -        break; -      case X86_VENDOR_ZHAOXIN:          mce_zhaoxin_feature_init(c);          break; @@ -1927,6 +1914,7 @@ static void __mcheck_cpu_clear_vendor(struct cpuinfo_x86 *c)          mce_intel_feature_clear(c);          break; +    case X86_VENDOR_CENTAUR:      case X86_VENDOR_ZHAOXIN:          mce_zhaoxin_feature_clear(c);          break; @@ -2233,9 +2221,10 @@ static void vendor_disable_error_reporting(void)       * controller (iMC), etc.       */      if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL || -        boot_cpu_data.x86_vendor == X86_VENDOR_HYGON || -        boot_cpu_data.x86_vendor == X86_VENDOR_AMD || -        boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) +        boot_cpu_data.x86_vendor == X86_VENDOR_HYGON || +        boot_cpu_data.x86_vendor == X86_VENDOR_AMD || +        boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR || +        boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN)          return;      mce_disable_error_reporting(); diff --git a/arch/x86/kernel/cpu/mce/intel.c b/arch/x86/kernel/cpu/mce/intel.c index abe9fe0fb851..26d521ac5f7d 100644 --- a/arch/x86/kernel/cpu/mce/intel.c +++ b/arch/x86/kernel/cpu/mce/intel.c @@ -86,7 +86,8 @@ static int cmci_supported(int *banks)       * makes sure none of the backdoors are entered otherwise.       */      if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL && -        boot_cpu_data.x86_vendor != X86_VENDOR_ZHAOXIN) +        boot_cpu_data.x86_vendor != X86_VENDOR_CENTAUR && +        boot_cpu_data.x86_vendor != X86_VENDOR_ZHAOXIN)          return 0;      if (!boot_cpu_has(X86_FEATURE_APIC) || lapic_get_maxlvt() < 6) -- 2.20.1
1 0
0 0
[PATCH OLK-5.10 1/2] Get locgical processors numbers bits per package
by LeoLiuoc 09 Jul '21

09 Jul '21
Get locgical processors numbers bits per package by cpuid instruction for some Zhaoxin CPUs which vendor is Centaur Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com> ---  arch/x86/kernel/cpu/centaur.c | 13 +++++++++++++  1 file changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c index 345f7d905db6..3d1e87b6a657 100644 --- a/arch/x86/kernel/cpu/centaur.c +++ b/arch/x86/kernel/cpu/centaur.c @@ -109,6 +109,19 @@ static void early_init_centaur(struct cpuinfo_x86 *c)          set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);          set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);      } + +    if (c->cpuid_level >= 0x00000001) { +        u32 eax, ebx, ecx, edx; + +        cpuid(0x00000001, &eax, &ebx, &ecx, &edx); +        /* +         * If HTT (EDX[28]) is set EBX[16:23] contain the number of +         * apicids which are reserved per package. Store the resulting +         * shift value for the package management code. +         */ +        if (edx & (1U << 28)) +            c->x86_coreid_bits = get_count_order((ebx >> 16) & 0xff); +    }  }  static void init_centaur(struct cpuinfo_x86 *c) -- 2.20.1
1 0
0 0
[PATCH OLK-5.10 2/2] Add support for extended topology detection,of Zhaoxin CPUs
by LeoLiuoc 09 Jul '21

09 Jul '21
Newer Zhaoxin CPUs support get extended topology from CPUID leaf B/1F, So add support for it. Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com> ---  arch/x86/kernel/cpu/centaur.c | 8 +++++++-  arch/x86/kernel/cpu/zhaoxin.c | 7 ++++++-  2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c index 3d1e87b6a657..dacac9135681 100644 --- a/arch/x86/kernel/cpu/centaur.c +++ b/arch/x86/kernel/cpu/centaur.c @@ -122,6 +122,9 @@ static void early_init_centaur(struct cpuinfo_x86 *c)          if (edx & (1U << 28))              c->x86_coreid_bits = get_count_order((ebx >> 16) & 0xff);      } + +    if (detect_extended_topology_early(c) < 0) +        detect_ht_early(c);  }  static void init_centaur(struct cpuinfo_x86 *c) @@ -140,11 +143,14 @@ static void init_centaur(struct cpuinfo_x86 *c)      clear_cpu_cap(c, 0*32+31);  #endif      early_init_centaur(c); +    detect_extended_topology(c);      init_intel_cacheinfo(c); -    detect_num_cpu_cores(c); +    if (!cpu_has(c, X86_FEATURE_XTOPOLOGY)) { +        detect_num_cpu_cores(c);  #ifdef CONFIG_X86_32      detect_ht(c);  #endif +    }      if (c->cpuid_level > 9) {          unsigned int eax = cpuid_eax(10); diff --git a/arch/x86/kernel/cpu/zhaoxin.c b/arch/x86/kernel/cpu/zhaoxin.c index 05fa4ef63490..2126b10de796 100644 --- a/arch/x86/kernel/cpu/zhaoxin.c +++ b/arch/x86/kernel/cpu/zhaoxin.c @@ -79,16 +79,21 @@ static void early_init_zhaoxin(struct cpuinfo_x86 *c)              c->x86_coreid_bits = get_count_order((ebx >> 16) & 0xff);      } +    if (detect_extended_topology_early(c) < 0) +        detect_ht_early(c);  }  static void init_zhaoxin(struct cpuinfo_x86 *c)  {      early_init_zhaoxin(c); +    detect_extended_topology(c);      init_intel_cacheinfo(c); -    detect_num_cpu_cores(c); +    if (!cpu_has(c, X86_FEATURE_XTOPOLOGY)) { +        detect_num_cpu_cores(c);  #ifdef CONFIG_X86_32      detect_ht(c);  #endif +    }      if (c->cpuid_level > 9) {          unsigned int eax = cpuid_eax(10); -- 2.20.1
1 0
0 0
[PATCH OLK-5.10 0/2] New Zhaoxin CPU vendor ID/FMS patch
by LeoLiuoc 09 Jul '21

09 Jul '21
This set of patches is to add support for Zhaoxin Family 7 CPUs. With these patches, the kernel can identify Zhaoxin CPUs topology information. LeoLiu-oc (2):   Get locgical processors numbers bits per package   Add support for extended topology detection of Zhaoxin CPUs  arch/x86/kernel/cpu/centaur.c | 21 ++++++++++++++++++++-  arch/x86/kernel/cpu/zhaoxin.c |  7 ++++++-  2 files changed, 26 insertions(+), 2 deletions(-) -- 2.20.1
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • Older →

HyperKitty Powered by HyperKitty