[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9AUUvfId9J66zWS@ryzen>
Date: Tue, 11 Mar 2025 11:45:38 +0100
From: Niklas Cassel <cassel@...nel.org>
To: Huacai Chen <chenhuacai@...ngson.cn>
Cc: Damien Le Moal <dlemoal@...nel.org>, linux-ide@...r.kernel.org,
Huacai Chen <chenhuacai@...nel.org>,
Xuerui Wang <kernel@...0n.name>,
Jiaxun Yang <jiaxun.yang@...goat.com>, linux-kernel@...r.kernel.org,
Yuli Wang <wangyuli@...ontech.com>, Jie Fan <fanjie@...ontech.com>,
Erpeng Xu <xuerpeng@...ontech.com>
Subject: Re: [PATCH V2] ahci: Marvell 88SE9215 controllers prefer DMA for
ATAPI
Hello Huacai Chen,
On Tue, Mar 11, 2025 at 11:02:17AM +0800, Huacai Chen wrote:
> We use CD/DVD drives under Marvell 88SE9215 SATA controller on many
> Loongson-based machines. We found its PIO doesn't work well, and on the
> opposite its DMA seems work very well. We don't know the detail of the
> 88SE9215 SATA controller, but we have tested different CD/DVD drives
> and they all have problems under 88SE9215 (but they all work well under
> an Intel SATA controller). So we can define a new AHCI board id named
> board_ahci_atapi_dma, and for this id we set the ATA_FLAG_ATAPI_DMA and
> ATA_QUIRK_ATAPI_MOD16_DMA flags on the SATA controller to prefer ATAPI
> DMA.
This patch does not apply.
It conflicts with:
https://web.git.kernel.org/pub/scm/linux/kernel/git/libata/linux.git/commit/?h=for-6.15&id=885251dc35767b1c992f6909532ca366c830814a
Please add Daniel to CC when you respin, so that he might also be able
to test.
>
> BTW, return -EOPNOTSUPP instead of 1 if ATAPI DMA is not supported in
> atapi_check_dma().
Please create a separate patch (e.g patch 1/2) for this with a proper
commit log. (A proper commit log should always answer the question: Why?)
>
> Reported-by: Yuli Wang <wangyuli@...ontech.com>
> Tested-by: Jie Fan <fanjie@...ontech.com>
> Tested-by: Erpeng Xu <xuerpeng@...ontech.com>
> Tested-by: Yuli Wang <wangyuli@...ontech.com>
> Signed-off-by: Huacai Chen <chenhuacai@...ngson.cn>
> ---
> drivers/ata/ahci.c | 12 ++++++++++++
> drivers/ata/libata-core.c | 6 +++++-
> include/linux/libata.h | 1 +
> 3 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index f813dbdc2346..a64db28549d8 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -49,6 +49,7 @@ enum board_ids {
> /* board IDs by feature in alphabetical order */
> board_ahci,
> board_ahci_43bit_dma,
> + board_ahci_atapi_dma,
> board_ahci_ign_iferr,
> board_ahci_no_debounce_delay,
> board_ahci_no_msi,
> @@ -137,6 +138,12 @@ static const struct ata_port_info ahci_port_info[] = {
> .udma_mask = ATA_UDMA6,
> .port_ops = &ahci_ops,
> },
> + [board_ahci_atapi_dma] = {
> + .flags = AHCI_FLAG_COMMON,
> + .pio_mask = ATA_PIO4,
> + .udma_mask = ATA_UDMA6,
> + .port_ops = &ahci_ops,
> + },
> [board_ahci_ign_iferr] = {
> AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR),
> .flags = AHCI_FLAG_COMMON,
> @@ -591,6 +598,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
> .driver_data = board_ahci_yes_fbs },
> { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230),
> .driver_data = board_ahci_yes_fbs },
> + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9215),
> + .driver_data = board_ahci_atapi_dma },
> { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9235),
> .driver_data = board_ahci_no_debounce_delay },
> { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642), /* highpoint rocketraid 642L */
> @@ -1917,6 +1926,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> /* save initial config */
> ahci_pci_save_initial_config(pdev, hpriv);
>
> + if (board_id == board_ahci_atapi_dma)
> + pi.flags |= ATA_FLAG_ATAPI_DMA;
> +
No need for these three lines, just rename your board_ahci_atapi_dma
board to board_ahci_atapi_dma_quirk_yes_fbs
and in the initialization of ahci_atapi_dma_quirk_yes_fbs, set:
AHCI_HFLAGS (AHCI_HFLAG_ATAPI_DMA_QUIRK |
AHCI_HFLAG_YES_FBS),
.flags = AHCI_FLAG_COMMON,
And rename ATA_FLAG_ATAPI_DMA to AHCI_HFLAG_ATAPI_DMA_QUIRK and put it in
AHCI_HFLAGS instead.
> /* prepare host */
> if (hpriv->cap & HOST_CAP_NCQ) {
> pi.flags |= ATA_FLAG_NCQ;
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index c085dd81ebe7..87a3dbf3ac93 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -3029,6 +3029,10 @@ int ata_dev_configure(struct ata_device *dev)
> dev->max_sectors = ATA_MAX_SECTORS;
> }
>
> + if ((dev->class == ATA_DEV_ATAPI) &&
> + (ap->flags & ATA_FLAG_ATAPI_DMA))
> + dev->quirks |= ATA_QUIRK_ATAPI_MOD16_DMA;
> +
> if ((dev->class == ATA_DEV_ATAPI) &&
> (atapi_command_packet_set(id) == TYPE_TAPE)) {
> dev->max_sectors = ATA_MAX_SECTORS_TAPE;
> @@ -4544,7 +4548,7 @@ int atapi_check_dma(struct ata_queued_cmd *qc)
> */
> if (!(qc->dev->quirks & ATA_QUIRK_ATAPI_MOD16_DMA) &&
> unlikely(qc->nbytes & 15))
> - return 1;
> + return -EOPNOTSUPP;
>
> if (ap->ops->check_atapi_dma)
> return ap->ops->check_atapi_dma(qc);
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index c1c57f814b98..67d374279a65 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -194,6 +194,7 @@ enum {
> /* (doesn't imply presence) */
> ATA_FLAG_SATA = (1 << 1),
> ATA_FLAG_NO_LPM = (1 << 2), /* host not happy with LPM */
> + ATA_FLAG_ATAPI_DMA = (1 << 4), /* ATAPI use DMA */
s/ATAPI use DMA/force ATAPI to use DMA/
> ATA_FLAG_NO_LOG_PAGE = (1 << 5), /* do not issue log page read */
> ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */
> ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */
> --
> 2.47.1
>
Kind regards,
Niklas
Powered by blists - more mailing lists