From: Damien Le Moal <dlemoal@kernel.org>
To: Hannes Reinecke <hare@suse.de>,
Phil Pemberton <philpem@philpem.me.uk>,
cassel@kernel.org, James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com
Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] ata: libata-scsi: enable multi-LUN support for ATAPI devices
Date: Tue, 14 Apr 2026 06:02:59 +0200 [thread overview]
Message-ID: <3d08e14c-2768-4126-882c-126113aea275@kernel.org> (raw)
In-Reply-To: <ba5e3570-ec42-4642-9dbe-2344a72adcff@suse.de>
On 2026/04/13 10:31, Hannes Reinecke wrote:
> On 4/12/26 21:40, Phil Pemberton wrote:
>> On 12/04/2026 08:38, Damien Le Moal wrote:
>>> On 4/9/26 23:05, Phil Pemberton wrote:
>>>> - Raises max_lun from 1 to 8 (matching the SCSI host default).
>>>> Sequential LUN scanning stops at the first non-responding LUN, so
>>>> single-LUN devices are unaffected.
>>>
>>> If the only case that we can encounter with libata are these special
>>> ATAPI
>>> devices with 2 LUNs, I would limit the maximum to 2.
>>
>> I'm inclined to agree, but there are devices with higher LUN counts: the
>> Nakamichi CD changers. The MJ-4.4 and MJ-5.16 were available in an ATAPI
>> variant which exposed a LUN for each disc in the changer stack. There's
>> a Cathode Ray Dude video demonstrating the latter.
>>
> Don't get too excited. This is ancient technology, with an extremely
> narrow user-base :-)
> 'Were available' is not identical to 'in current use', and I'm somewhat
> disinclined to add support for technology with no users.
>
>> I like the idea of the lower LUN cap for compatibility, but I think I'd
>> hedge bets by also having a module parameter (e.g. libata.atapi_max_lun)
>> to override it. Default 2 seems like a good compromise.
>>
> Hmm. I really would like to restrict max lun to 1 (as it somewhat mimics
> the master/slave thingie on IDE). But higher than that really is
> arbitrary; the next sensible limit would be '7', as this is what SCSI-2
> could handle. I completely fail to see the motivation to have a limit
> somewhere in between.
>
>> In any case, the BLIST_FORCELUN gate should limit things to one LUN for
>> any device which isn't on the device list.
>>
>>
>>>> - ata_scsi_dev_config() previously assigned dev->sdev = sdev for
>>>> every
>>>> LUN configured. With multiple LUNs sharing one ata_device, this
>>>> caused dev->sdev to be overwritten by each non-LUN-0 sdev.
>>>> Restrict
>>>> the assignment to LUN 0 so that dev->sdev always tracks the
>>>> canonical scsi_device for the underlying ATA device.
>>>
>>> Special casing this does not seem nice at all. Why not simply
>>> increasing the
>>> sdev reference count when it is assigned to a LUN that is not LUN 0 ?
>>> And drop
>>> that reference when the LUN is torn down ? That will remove any
>>> dependency on
>>> the order in which LUNs are torn down too.
>>
>> The if (sdev->lun == 0) guard isn't about teardown ordering; it's about
>> which device dev->sdev points at.
>>
>> dev->sdev is a single pointer, but with multi-LUN ATAPI there are now
>> multiple sdevs sharing one ata_device. Without the guard, each call to
>> ata_scsi_dev_config() overwrites the pointer, so it ends up tracking the
>> last-configured LUN (likely the highest-numbered one).
>>
> And how would you address the 'sdev' of LUN 1?
> (and how of LUN 2, if we decide to have one?)
>
> Please, don't. The correct way would be to convert 'dev->sdev' into
> a list.
Or an array sized to the max number of LUNs we allow (7 ?). That would be way
easier to handle than a list I think since we can index that by LUN number.
Unless LUNs can have any number ? I did not check...
And checking suspend/resume will be needed as we likely will need to keep track
of the number of LUNs already suspended before being able to suspend the port.
scsi layer should already be doing something like that for the scsi host though
(host == port here), so luckily, that should not too bad to handle.
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-04-14 4:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 21:05 [RFC PATCH 0/3] ata: libata-scsi: add multi-LUN support for ATAPI devices Phil Pemberton
2026-04-09 21:05 ` [PATCH 1/3] scsi: scsi_devinfo: add COMPAQ PD-1 multi-LUN ATAPI device quirk Phil Pemberton
2026-04-12 7:25 ` Damien Le Moal
2026-04-09 21:05 ` [PATCH 2/3] ata: libata-scsi: enable multi-LUN support for ATAPI devices Phil Pemberton
2026-04-12 7:38 ` Damien Le Moal
2026-04-12 19:40 ` Phil Pemberton
2026-04-13 5:43 ` Damien Le Moal
2026-04-13 8:31 ` Hannes Reinecke
2026-04-14 4:02 ` Damien Le Moal [this message]
2026-04-09 21:05 ` [PATCH 3/3] ata: libata-scsi: probe additional LUNs for multi-LUN " Phil Pemberton
2026-04-12 7:41 ` Damien Le Moal
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=3d08e14c-2768-4126-882c-126113aea275@kernel.org \
--to=dlemoal@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=cassel@kernel.org \
--cc=hare@suse.de \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=philpem@philpem.me.uk \
/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