linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>,
	Jason Yan <yanaijie@huawei.com>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH v2 12/13] ata,scsi: Remove useless ata_sas_port_alloc() wrapper
Date: Thu, 27 Jun 2024 11:48:14 +0200	[thread overview]
Message-ID: <Zn01XqPMga6aG1nL@ryzen.lan> (raw)
In-Reply-To: <83125236-7d07-4b62-b86a-5a70f3ca578e@kernel.org>

On Thu, Jun 27, 2024 at 10:46:11AM +0900, Damien Le Moal wrote:
> On 6/27/24 03:00, Niklas Cassel wrote:
> > Now when the ap->print_id assignment has moved to ata_port_alloc(),
> > we can remove the useless ata_sas_port_alloc() wrapper.
> 
> Same comment as for patch 4: not a fan.
> 
> But I do like the fact that the port additional initialization is moved to
> libsas, as that code is completely dependent on libsas.
> 
> What about this cleanup, which would make more sense:
> 
> 1) Keep the ata_sas_xxx() exported symbols, even if they are trivial.
> 2) Move all these wrappers to a new file (libata-sas.c) and make this file
> compilation dependend on CONFIG_SATA_HOST and CONFIG_SCSI_SAS_LIBSAS.
> 
> That has the benefit of keeping all the libsas wrappers together and to reduce
> the binary size for configs that do not enable libsas.
> 
> Thoughts ?

I think that:

1) These wrappers are like a virus... they are completely useless and
   having them will force us to keep adding new wrappers, e.g. we would
   need to add a new wrapper for ata_port_free().

2) Having a wrapper that simply does an EXPORT_SYMBOL is not only useless,
it also makes it harder to know that the function (called by the wrapper)
is actually non-internal, since the function will be defined in the libata
internal header in drivers/ata/libata.h, so you might think that it is an
internal function... but it isn't, since there is a wrapper exporting it :)

3) The naming prefix argument does not hold up.
   If you do a:

$ git grep -E "\s+ata_\S+\(" v6.10-rc5 drivers/scsi/libsas/
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_qc_complete(qc);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, (u8 *)&task->ata_task.fis);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        task->ata_task.use_ncq = ata_is_ncq(qc->tf.protocol);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        task->ata_task.dma_xfer = ata_is_dma(qc->tf.protocol);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_tf_from_fis(dev->sata_dev.fis, &qc->result_tf);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_tf_from_fis(dev->frame_rcvd, &tf);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        return ata_dev_classify(&tf);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ret = ata_wait_after_reset(link, deadline, check_ready);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_std_sched_eh(ap);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_host_init(ata_host, ha->dev, &sas_sata_ops);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ap = ata_sas_port_alloc(ata_host, &sata_port_info, shost);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        rc = ata_sas_tport_add(ata_host->dev, ap);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_host_put(ata_host);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:                ata_port_probe(dev->sata_dev.ap);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:                ata_sas_port_suspend(sata->ap);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:                ata_sas_port_resume(sata->ap);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_scsi_port_error_handler(ha->shost, ap);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:                        ata_scsi_cmd_error_handler(shost, ap, &sata_q);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:                         * action will be ata_port_error_handler()
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_port_schedule_eh(ap);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_port_wait_eh(ap);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        ata_link_abort(link);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        rc = ata_ncq_prio_supported(ddev->sata_dev.ap, sdev, &supported);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        rc = ata_ncq_prio_enabled(ddev->sata_dev.ap, sdev, &enabled);
v6.10-rc5:drivers/scsi/libsas/sas_ata.c:        rc = ata_ncq_prio_enable(ddev->sata_dev.ap, sdev, enable);
v6.10-rc5:drivers/scsi/libsas/sas_discover.c:           ata_sas_tport_delete(dev->sata_dev.ap);
v6.10-rc5:drivers/scsi/libsas/sas_discover.c:           ata_host_put(dev->sata_dev.ata_host);
v6.10-rc5:drivers/scsi/libsas/sas_scsi_host.c:          res = ata_sas_queuecmd(cmd, dev->sata_dev.ap);
v6.10-rc5:drivers/scsi/libsas/sas_scsi_host.c:          return ata_sas_scsi_ioctl(dev->sata_dev.ap, sdev, cmd, arg);
v6.10-rc5:drivers/scsi/libsas/sas_scsi_host.c:          ata_sas_device_configure(scsi_dev, lim, dev->sata_dev.ap);
v6.10-rc5:drivers/scsi/libsas/sas_scsi_host.c:          return ata_change_queue_depth(dev->sata_dev.ap, sdev, depth);

You will see that far from all libata functions have ata_sas_*() wrapper,
so all the ata_* functions that do not not have ata_sas_*() wrapper are
already exported using EXPORT_SYMBOL_GPL(), i.e.:

ata_qc_complete(), ata_tf_to_fis(), ata_tf_from_fis(), ata_dev_classify(),
ata_wait_after_reset(), ata_std_sched_eh(), ata_host_init(), ata_host_put(),
ata_port_probe(), ata_scsi_port_error_handler(), ata_scsi_cmd_error_handler(),
ata_port_schedule_eh(), ata_link_abort(), ata_ncq_prio_supported(),
ata_ncq_prio_enabled(), ata_ncq_prio_enable(), ata_change_queue_depth()
are already exported using EXPORT_SYMBOL_GPL().

(And yes, some of these exported functions not used by any libata SATA driver
(compiled as a separate .ko) other than libsas.)


TL;DR: I really think that we should kill these wrappers.


Kind regards,
Niklas

  reply	other threads:[~2024-06-27  9:48 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26 18:00 [PATCH v2 00/13] ata,libsas: Assign the unique id used for printing earlier Niklas Cassel
2024-06-26 18:00 ` [PATCH v2 01/13] ata: libata-core: Fix null pointer dereference on error Niklas Cassel
2024-06-27  1:00   ` Damien Le Moal
2024-06-27  6:24   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 02/13] ata: libata-core: Fix double free " Niklas Cassel
2024-06-27  1:02   ` Damien Le Moal
2024-06-27  6:25   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 03/13] ata: ahci: Clean up sysfs file " Niklas Cassel
2024-06-26 18:34   ` Niklas Cassel
2024-06-27  1:04   ` Damien Le Moal
2024-06-27  6:28   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 04/13] ata,scsi: Remove useless wrappers ata_sas_tport_{add,delete}() Niklas Cassel
2024-06-27  1:07   ` Damien Le Moal
2024-06-27  6:29   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 05/13] ata,scsi: libata-core: Add ata_port_free() Niklas Cassel
2024-06-27  1:15   ` Damien Le Moal
2024-06-29 12:09     ` Niklas Cassel
2024-06-27  6:30   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 06/13] ata: libata: Remove unused function declaration for ata_scsi_detect() Niklas Cassel
2024-06-27  1:16   ` Damien Le Moal
2024-06-27  6:31   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 07/13] ata: libata-core: Remove support for decreasing the number of ports Niklas Cassel
2024-06-26 19:30   ` Niklas Cassel
2024-06-27  1:30   ` Damien Le Moal
2024-06-27  6:35   ` Hannes Reinecke
2024-06-29 12:24     ` Niklas Cassel
2024-06-26 18:00 ` [PATCH v2 08/13] ata: libata-sata: Remove superfluous assignment in ata_sas_port_alloc() Niklas Cassel
2024-06-27  1:31   ` Damien Le Moal
2024-06-27  6:37   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 09/13] ata: libata-core: Remove local_port_no struct member Niklas Cassel
2024-06-27  1:33   ` Damien Le Moal
2024-06-27  6:37   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 10/13] ata: libata: Assign print_id at port allocation time Niklas Cassel
2024-06-27  6:38   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 11/13] ata: libata-core: Reuse available ata_port print_ids Niklas Cassel
2024-06-27  1:37   ` Damien Le Moal
2024-07-02 15:43     ` Niklas Cassel
2024-06-27  6:39   ` Hannes Reinecke
2024-06-28 16:31   ` kernel test robot
2024-06-28 18:15     ` Niklas Cassel
2024-06-26 18:00 ` [PATCH v2 12/13] ata,scsi: Remove useless ata_sas_port_alloc() wrapper Niklas Cassel
2024-06-27  1:46   ` Damien Le Moal
2024-06-27  9:48     ` Niklas Cassel [this message]
2024-06-28  3:46       ` Damien Le Moal
2024-06-27  6:40   ` Hannes Reinecke
2024-06-26 18:00 ` [PATCH v2 13/13] ata: ahci: Add debug print for external port Niklas Cassel
2024-06-27  6:40   ` Hannes Reinecke
2024-06-27 12:26 ` [PATCH v2 00/13] ata,libsas: Assign the unique id used for printing earlier John Garry
2024-06-27 12:32   ` Niklas Cassel
2024-06-27 12:54     ` John Garry
2024-06-27 15:07       ` Niklas Cassel
2024-07-02 15:43         ` Niklas Cassel

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=Zn01XqPMga6aG1nL@ryzen.lan \
    --to=cassel@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=dlemoal@kernel.org \
    --cc=john.g.garry@oracle.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=yanaijie@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).