Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp998460lqs; Wed, 6 Mar 2024 03:22:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX7kciV3gushCWBOzUwuxRqtI0xwW8b1ZclEN1hpC0Yl7i58RIdF83wYZRb8U3x3f30q7UGxez8a4/7f4UQcLv0ClW9/OGcqjnmJ5iGKA== X-Google-Smtp-Source: AGHT+IG9BZYDXj+VlyBV6CkuBtyni9vuTux7Wd7w1tZvm//xnyMIrDuzmhlODXZujm9TI9l6VWrw X-Received: by 2002:a17:90a:1049:b0:29b:b70:5ace with SMTP id y9-20020a17090a104900b0029b0b705acemr13028519pjd.16.1709724172272; Wed, 06 Mar 2024 03:22:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709724172; cv=pass; d=google.com; s=arc-20160816; b=0rRKyMvRNFZWAuWaJOMcFaXGS1NV2vQ/26H/q4rC8BubpieZxjRU1BFy8WQgyeFSjw VMkFsZefrqrwwCjqiDJD4mzvhFXhBe9UVxvT1KM+qsVIbCzdpbR8lLGUbYE3ksXCXv+y qhn8Xjcmhzx68Fs1eHPJwcXDI3Z0bG+Oq+/A5uU3Z6jRzNyNMmLhiyIttUsbX3kTCJJA mMjxCnKvuRdeYOf0WowA+zFVY3xRc5wgqIYDdhVfARNQqOZ+upq0KOyuSGhhKalUwDRd mpQAY3386Iv5PGwe8G/nFX+mpNRtVKCnvv3jCV4vQ63xa+nGLU8o6bUdyLGvRZGCLL2/ conQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XQmiR2CWx1KB0tgmhwcHT2sTK/K+B6JcF6vhv2fdIAM=; fh=qi4kBeskBymI5w6NsMzc1dDuT1ws3vjEt5D3JlipxIk=; b=eJvL/xfNk6OHXwisx6dldJbXSzMg5Vfeh9YzYB6okqvf7oqQTIqqiJRnTuIUD/8IZS W4WVgiQRhn3yO7Yr6tw+I8RdTt0Z/psrIuiwIXBue1qTwJYMdAqByLwec5d8aSp3DM9l NdkPUTlCAYnanAlNTFNQauQtrAzx1XeOTvZMpqN9fTICWzK3937CPw+inpHlzxbRfkSe IyV61yrgIegTo2rZZawt3PrzPBFD3AII7S3x3ohBBKnoR7j6exSLzWA2V5HvTg0m/K0x 9NmOgXEIZd7p8VpyxwEoIpuaDOCiDcILVqjASo+HWEYne9y9CUeEJIJ/yK7Z35owrMn3 APQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XvsFxFGA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id kk15-20020a17090b4a0f00b0029b742b4375si1252271pjb.42.2024.03.06.03.22.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 03:22:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XvsFxFGA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0B789B2B706 for ; Wed, 6 Mar 2024 10:55:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 006E860B88; Wed, 6 Mar 2024 10:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XvsFxFGA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBA07605C7; Wed, 6 Mar 2024 10:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709722499; cv=none; b=YGXpstILDSt/IaoaiesReDHaPj12eYFs0DEWAdK08ZgHfiDY2dGRhrHGIxqFsMOsCgnhHT790NzNYzU0JVCLqzWy18JulcGAnyUB2lCU2YO1QSQvQ0EBapTRdEmA8RvuxE1fdXtZtYqR7rDzMx//qiGGATWW4XIZVPpDwFR4O9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709722499; c=relaxed/simple; bh=YD76MHec5dML9IBNBcREwvR+mmv0kGcOikse6uycZfg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z31shZ9QPpuib+zsZ/pEec18wFk5ZbtKZDvPcJLoaSRfqth9TIcahMxZaNrWXl6b5CoWW+tqQ/6BrtaLq5BE4ZRyyFKqZtTHJ3pFZRdhsD6Lhb83ZX0WfXIAT5tJFjWhlTCwI9ug8gnKqZRRNj4UOHGzmNaFvZd4/3JC4jvHC/Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XvsFxFGA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6544EC433F1; Wed, 6 Mar 2024 10:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709722498; bh=YD76MHec5dML9IBNBcREwvR+mmv0kGcOikse6uycZfg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XvsFxFGA2A344AqJMB4bRs6pg36ysD5qabRGt1hRUIvy0UxjsZJYzfnX+LZNmW/e2 anidCR0T9oW9CzOAdgUC7Eobo8eBdiQ17yZtfOnVcao2QLH4styBVBFWsaOitijb6W uafUBuKnB21GJdLXc94AkEgQL7JMRIk5+eEKEdmIsOasnPZ7BNzk2Chmt97ygtW6VD /bxfw3x81Y1S5YWtuTDEPb4HVtsotw+Uxf9wkSYiyWYzOqta33SPUM7p/zfdbQczZB EibXXd2l26t/2Z8XKU3Y+gDG2qEt8PD8zfkD9ICMUo49r8eO0rgC/W17qtqoa7mpAX PH1L/zpsoFzWQ== Date: Wed, 6 Mar 2024 11:54:52 +0100 From: Niklas Cassel To: Igor Pylypiv Cc: Damien Le Moal , John Garry , Jason Yan , "James E.J. Bottomley" , "Martin K. Petersen" , Jack Wang , Hannes Reinecke , Xiang Chen , Artur Paszkiewicz , Bart Van Assche , TJ Adams , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 2/7] scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices Message-ID: References: <20240306012226.3398927-1-ipylypiv@google.com> <20240306012226.3398927-3-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240306012226.3398927-3-ipylypiv@google.com> On Tue, Mar 05, 2024 at 05:22:21PM -0800, Igor Pylypiv wrote: > Libata sysfs attributes cannot be used for libsas managed SATA devices > because the ata_port location is different for libsas. > > Defined sysfs attributes (visible for SATA devices only): > - /sys/block/sda/device/ncq_prio_enable > - /sys/block/sda/device/ncq_prio_supported > > The newly defined attributes will pass the correct ata_port to libata > helper functions. > > Reviewed-by: John Garry > Reviewed-by: Damien Le Moal > Reviewed-by: Jason Yan > Signed-off-by: Igor Pylypiv > --- > drivers/scsi/libsas/sas_ata.c | 94 +++++++++++++++++++++++++++++++++++ > include/scsi/sas_ata.h | 6 +++ > 2 files changed, 100 insertions(+) > > diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c > index 12e2653846e3..04b0bd9a4e01 100644 > --- a/drivers/scsi/libsas/sas_ata.c > +++ b/drivers/scsi/libsas/sas_ata.c > @@ -964,3 +964,97 @@ int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id) > force_phy_id, &tmf_task); > } > EXPORT_SYMBOL_GPL(sas_execute_ata_cmd); > + > +static ssize_t sas_ncq_prio_supported_show(struct device *device, > + struct device_attribute *attr, > + char *buf) > +{ > + struct scsi_device *sdev = to_scsi_device(device); > + struct domain_device *ddev = sdev_to_domain_dev(sdev); > + bool supported; > + int rc; > + > + /* This attribute shall be visible for SATA devices only */ > + if (WARN_ON_ONCE(!dev_is_sata(ddev))) > + return -EINVAL; Like Hannes commented, I don't believe this is needed. > + > + rc = ata_ncq_prio_supported(ddev->sata_dev.ap, sdev, &supported); > + if (rc) > + return rc; > + > + return sysfs_emit(buf, "%d\n", supported); > +} > + While this is a bit different depending on file, the most common way is to have no blank link before the DEVICE_ATTR(). > +DEVICE_ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL); > + > +static ssize_t sas_ncq_prio_enable_show(struct device *device, > + struct device_attribute *attr, > + char *buf) > +{ > + struct scsi_device *sdev = to_scsi_device(device); > + struct domain_device *ddev = sdev_to_domain_dev(sdev); > + bool enabled; > + int rc; > + > + /* This attribute shall be visible for SATA devices only */ > + if (WARN_ON_ONCE(!dev_is_sata(ddev))) > + return -EINVAL; > + > + rc = ata_ncq_prio_enabled(ddev->sata_dev.ap, sdev, &enabled); > + if (rc) > + return rc; > + > + return sysfs_emit(buf, "%d\n", enabled); > +} > + > +static ssize_t sas_ncq_prio_enable_store(struct device *device, > + struct device_attribute *attr, > + const char *buf, size_t len) > +{ > + struct scsi_device *sdev = to_scsi_device(device); > + struct domain_device *ddev = sdev_to_domain_dev(sdev); > + bool enable; > + int rc; > + > + /* This attribute shall be visible for SATA devices only */ > + if (WARN_ON_ONCE(!dev_is_sata(ddev))) > + return -EINVAL; > + > + rc = kstrtobool(buf, &enable); > + if (rc) > + return rc; > + > + rc = ata_ncq_prio_enable(ddev->sata_dev.ap, sdev, enable); > + if (rc) > + return rc; > + > + return len; > +} > + > +DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR, > + sas_ncq_prio_enable_show, sas_ncq_prio_enable_store); > + > +static struct attribute *sas_ata_sdev_attrs[] = { > + &dev_attr_ncq_prio_supported.attr, > + &dev_attr_ncq_prio_enable.attr, > + NULL > +}; > + > +static umode_t sas_ata_attr_is_visible(struct kobject *kobj, > + struct attribute *attr, int i) > +{ > + struct device *dev = kobj_to_dev(kobj); > + struct scsi_device *sdev = to_scsi_device(dev); > + struct domain_device *ddev = sdev_to_domain_dev(sdev); > + > + if (!dev_is_sata(ddev)) > + return 0; > + > + return attr->mode; > +} > + > +const struct attribute_group sas_ata_sdev_attr_group = { > + .attrs = sas_ata_sdev_attrs, > + .is_visible = sas_ata_attr_is_visible, > +}; > +EXPORT_SYMBOL_GPL(sas_ata_sdev_attr_group); > diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h > index 2f8c719840a6..92e27e7bf088 100644 > --- a/include/scsi/sas_ata.h > +++ b/include/scsi/sas_ata.h > @@ -39,6 +39,9 @@ int smp_ata_check_ready_type(struct ata_link *link); > int sas_discover_sata(struct domain_device *dev); > int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, > struct domain_device *child, int phy_id); > + > +extern const struct attribute_group sas_ata_sdev_attr_group; > + > #else > > static inline void sas_ata_disabled_notice(void) > @@ -123,6 +126,9 @@ static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *p > sas_ata_disabled_notice(); > return -ENODEV; > } > + > +#define sas_ata_sdev_attr_group ((struct attribute_group) {}) > + > #endif > > #endif /* _SAS_ATA_H_ */ > -- > 2.44.0.278.ge034bb2e1d-goog >