From: Niklas Cassel <cassel@kernel.org>
To: Huacai Chen <chenhuacai@loongson.cn>
Cc: Damien Le Moal <dlemoal@kernel.org>,
linux-ide@vger.kernel.org, Huacai Chen <chenhuacai@kernel.org>,
Xuerui Wang <kernel@xen0n.name>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
linux-kernel@vger.kernel.org, Yuli Wang <wangyuli@uniontech.com>,
Jie Fan <fanjie@uniontech.com>,
Erpeng Xu <xuerpeng@uniontech.com>
Subject: Re: [PATCH V2] ahci: Marvell 88SE9215 controllers prefer DMA for ATAPI
Date: Tue, 11 Mar 2025 11:45:38 +0100 [thread overview]
Message-ID: <Z9AUUvfId9J66zWS@ryzen> (raw)
In-Reply-To: <20250311030217.4177569-1-chenhuacai@loongson.cn>
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@uniontech.com>
> Tested-by: Jie Fan <fanjie@uniontech.com>
> Tested-by: Erpeng Xu <xuerpeng@uniontech.com>
> Tested-by: Yuli Wang <wangyuli@uniontech.com>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.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
next prev parent reply other threads:[~2025-03-11 10:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 3:02 [PATCH V2] ahci: Marvell 88SE9215 controllers prefer DMA for ATAPI Huacai Chen
2025-03-11 10:45 ` Niklas Cassel [this message]
2025-03-12 13:34 ` Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9AUUvfId9J66zWS@ryzen \
--to=cassel@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=dlemoal@kernel.org \
--cc=fanjie@uniontech.com \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wangyuli@uniontech.com \
--cc=xuerpeng@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.