Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp900035lqs; Tue, 5 Mar 2024 23:14:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5BX7B1cXHCcYCmsJo7iWsGgx89+jxLx9uqV4vRBlzk9k6xryiyUCzV7+8WHMH6IQPoqjjEUIK8kjiDWmr9IBrljfd78wJNAE1HTHhjQ== X-Google-Smtp-Source: AGHT+IG98YW1CuMKvEvoj1qjakhmurMTvEhUY3GyadFTra6u3JyHTskhw6KOByg6uyKsA2tUnrTL X-Received: by 2002:a05:6402:f8f:b0:563:bd95:4ef8 with SMTP id eh15-20020a0564020f8f00b00563bd954ef8mr9176344edb.23.1709709264809; Tue, 05 Mar 2024 23:14:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709709264; cv=pass; d=google.com; s=arc-20160816; b=e5b7IgQ6/buFlk6GGotVzezlUY5aPGvM5VGXt8BUp4g+n2MsYteYKs3l2mW5i0CxMU KhhTll7/YTlbs9Ybii0UkbxCY4lenbzWK4i9yx3RxqlOuvglzGqbfSzJrZm18gK9CUT6 uufu2NwA3QI1l4R0XQGEwehyPg57UxSbBvgZmbJPNOasJd7bB1ZH3G6PEVH9jDNw+wJS vKo5aAy/0LJkXFGkW6agu3UJ7wkpwd3mCrFrcGmmDFHjyWLnuMw1AK/AurMYESnyutru ZQ73FfQsOHIrbVowJbNkmCqGgx8aY0/1+6nbJb80n20Iu7VKLkhbOK9YaLHinU9WEJE6 sKOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=y+lCFStqJhRgrujaxA2G7OrESQahwJduS9yoJsutlHU=; fh=gEQoj9422v6YxeQPPpaRlVDO5QIZFgLAHW+6Fym6ArQ=; b=Va3OIrF3y74Lwktt09PdDMhpGZpFoAX3kK5IJ4bjsU1sh7ToOIq62kqgCoS8HJAXPx 4cnEt8cIrhj4ksfXHfIGp/VjnMlvgBp5KX8NaD6UJ4C4cyzMr3KG3bWVPYxdX8P3bhep njhz/e45eqesm7IKaqsjT/wBgt+Y71LjBaLhKIxSZwc0fguI2kFSylqFXuDVs0rEkpdi OkxibRlsSB8WsYzzdVCl6ir006Bqq6L+eHC8bV3/Sj+r3u/dq+upDmDuSeKTH8JDUaiw GQGAxSn9fMPDWT0GVWbLumJ5xzOCdVcb22k/38pAWA6d4S5/9GmZOdoWWwNFsvCpJ1MZ /pUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=eFqlF7SY; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LKUwrPPn; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-93406-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93406-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dk7-20020a0564021d8700b00566b0e52eb9si5543348edb.516.2024.03.05.23.14.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 23:14:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93406-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=eFqlF7SY; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LKUwrPPn; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-93406-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93406-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6284D1F23B89 for ; Wed, 6 Mar 2024 07:14:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 036785C5FC; Wed, 6 Mar 2024 07:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="eFqlF7SY"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="28spvLDT"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="LKUwrPPn"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="twKdFAQo" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49DE01427E; Wed, 6 Mar 2024 07:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709709252; cv=none; b=gqh3vhi3zlNXniZLSckq9OuEsUTQ3FHUzrbEeXCgXeNdMP6GQ4aCAvfEKHcs+/resYITISwHYIkJXxPcL263eL8G+MFnve8831hoTrvoERhZlDjSYYE7QpdTgJPq8hwFOeo8bQ38N6APXL1nO/cWixgOnFOl+/sE/PL4IEWZc6I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709709252; c=relaxed/simple; bh=TRzvoJhUB5lFksiERRyjBbOWUn5zGGUZW6M+gsKhq8s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TdVCvk6N2zxhoIXJtKUasM81WOU39zsBfcFX9SHbD419x9Pma3FTGXlhb134saygLkVGSCeSnbPKmeZU2kHNOWqs4CBIdPsFLoVhkxc1xjzuP/4zL+PSeJpRF4NTKLOVWF3Jjv/x+Me7wppXQRKVl+9m3X03+wvyuhIy0gaKEIc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=eFqlF7SY; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=28spvLDT; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=LKUwrPPn; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=twKdFAQo; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8A64366FB6; Wed, 6 Mar 2024 07:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709709248; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y+lCFStqJhRgrujaxA2G7OrESQahwJduS9yoJsutlHU=; b=eFqlF7SYyemx9Bui/sr3aTwjd7IoB4AlWAr3Cpc3rMPi8YfM43Q73CY5Zo51Tiwo2tEfpy +Gk5rmvKzPgS4UEuqHMuUe8UskO1wMdHATDymTn9Bxfk7TtP49f4mQ+H6bR5bVq2ROWwB3 Fh6VdGIKYTMkEWTS1zQLrdWz0+dg9C8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709709248; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y+lCFStqJhRgrujaxA2G7OrESQahwJduS9yoJsutlHU=; b=28spvLDTn06AJOQcFFTzuqhho9GZwOTxEs/AtkwEustz0eK2loFU049cFOvT251TPB87K4 GXU/xKjq22VeH7CQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709709246; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y+lCFStqJhRgrujaxA2G7OrESQahwJduS9yoJsutlHU=; b=LKUwrPPnWVkqC5pQlk/e9rRDkdwThkEUEj6vqAe7qCHzSMkJCffovdnMqRxcSPGs4zUcPb HycGqjCXc2A54ufvAayDC8uBdoqWwP1f+ciuG8hPwLbaJdUzSyyGdw/ZMhm6M3EuFhCGb8 KRMvPoWy5Xe6sciy2udt0r/oo8BudZM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709709246; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y+lCFStqJhRgrujaxA2G7OrESQahwJduS9yoJsutlHU=; b=twKdFAQowdFoIiiNVtPwq6ry3GpPEuN7EWwHkqNB2QVshgtIxzzq5vl21TdF8Lh8nTteyv bW9RDPhylqm+kdAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E7BCF13A9C; Wed, 6 Mar 2024 07:14:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id q3y5Nr0X6GWbVgAAD6G6ig (envelope-from ); Wed, 06 Mar 2024 07:14:05 +0000 Message-ID: Date: Wed, 6 Mar 2024 08:14:04 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 2/7] scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices Content-Language: en-US To: Igor Pylypiv , Damien Le Moal , Niklas Cassel , John Garry , Jason Yan , "James E.J. Bottomley" , "Martin K. Petersen" , Jack Wang , Xiang Chen , Artur Paszkiewicz , Bart Van Assche Cc: TJ Adams , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240305235823.3308225-1-ipylypiv@google.com> <20240305235823.3308225-3-ipylypiv@google.com> From: Hannes Reinecke In-Reply-To: <20240305235823.3308225-3-ipylypiv@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -4.29 X-Spamd-Result: default: False [-4.29 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-0.985]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWELVE(0.00)[15]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,huawei.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO On 3/6/24 00:58, 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; > + You don't need the WARN_ON here; the 'is_visible' function will take care of it. > + rc = ata_ncq_prio_supported(ddev->sata_dev.ap, sdev, &supported); > + if (rc) > + return rc; > + > + return sysfs_emit(buf, "%d\n", supported); > +} > + > +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; > + Same here. > + 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; > + And here. > + 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..59a75cd8b5e0 100644 > --- a/include/scsi/sas_ata.h > +++ b/include/scsi/sas_ata.h > @@ -39,6 +39,8 @@ 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 +125,10 @@ static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *p > sas_ata_disabled_notice(); > return -ENODEV; > } > + > +static const struct attribute_group sas_ata_sdev_attr_group __maybe_unused = { > + .attrs = NULL, > +}; > #endif > > #endif /* _SAS_ATA_H_ */ Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich