[Intel-wired-lan] [PATCH iwl-net v2] ice: use DSN instead of PCI BDF for ice_adapter index

Przemek Kitszel przemyslaw.kitszel at intel.com
Mon Apr 7 13:26:38 UTC 2025


>> struct ice_adapter {
>> 	refcount_t refcount;
>> 	/* For access to the GLTSYN_TIME register */
>> 	spinlock_t ptp_gltsyn_time_lock;
>>
>> 	struct ice_pf *ctrl_pf;
>> 	struct ice_port_list ports;
>> +	u64 device_serial_number;
>> };
>>


>> +	index = ice_adapter_index(dsn);
>> 	scoped_guard(mutex, &ice_adapters_mutex) {
>> 		err = xa_insert(&ice_adapters, index, NULL, GFP_KERNEL);
>> 		if (err == -EBUSY) {
>> 			adapter = xa_load(&ice_adapters, index);
>> 			refcount_inc(&adapter->refcount);
>> +			WARN_ON_ONCE(adapter->device_serial_number != dsn);
> 
> Warn and done? How unlikely is this? I mean, can this happen in real
> world? If yes, that's a bug.

Very unlikely, one would have to have weird NVM *and* also running
32bit mode, I don't like complicating the normal flow to be able to
run fine on misconfigured setups. One redundant field in the struct
and an unlikely() branch on the init path already is almost too much
for my liking, but human will get to know immediately.



More information about the Intel-wired-lan mailing list